Skip to content

Commit

Permalink
Add error investigation
Browse files Browse the repository at this point in the history
  • Loading branch information
kochounoyume committed Jul 3, 2024
1 parent 3022f27 commit a82cf96
Showing 1 changed file with 46 additions and 4 deletions.
50 changes: 46 additions & 4 deletions Packages/PlayerControl/Runtime/PlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,46 @@ protected Quaternion WorldRotation

protected virtual void Start()
{
transform = GetComponent<ITransform>();
constants = new AnimHashConstants();
PlayerInput.onActionTriggered += context => OnActionTriggered(context);
JumpControl.OnJump.AddListener(OnJump);
try
{
transform = GetComponent<ITransform>();
}
catch (Exception e)
{
Exception ee = new Exception("Failed to get the ITransform component.", e);
Debug.LogException(ee);
throw;
}
try
{
constants = new AnimHashConstants();
}
catch (Exception e)
{
Exception ee = new Exception("Failed to create the AnimHashConstants.", e);
Debug.LogException(ee);
throw;
}
try
{
PlayerInput.onActionTriggered += context => OnActionTriggered(context);
}
catch (Exception e)
{
Exception ee = new Exception("Failed to set the action triggered event.", e);
Debug.LogException(ee);
throw;
}
try
{
JumpControl.OnJump.AddListener(OnJump);
}
catch (Exception e)
{
Exception ee = new Exception("Failed to set the jump event.", e);
Debug.LogException(ee);
throw;
}
}

protected virtual void Update()
Expand All @@ -141,6 +177,12 @@ protected virtual void Update()
{
Animator.SetFloat(constants.Speed, CurrentSpeed);
}
catch (NullReferenceException e) when (constants == null)
{
Exception ee = new Exception("Failed to set the speed parameter in constants.", e);
Debug.LogException(ee);
throw;
}
catch (Exception e)
{
Exception ee = new Exception("Failed to set the speed parameter.", e);
Expand Down

0 comments on commit a82cf96

Please sign in to comment.