Skip to content

Commit b0dd048

Browse files
committed
Fix for lack of stacktrace in exceptions thrown by states
1 parent 487c244 commit b0dd048

File tree

3 files changed

+21
-23
lines changed

3 files changed

+21
-23
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Change Log
22

3+
# [0.10.2-beta] - Feb 05, 2025
4+
- Fix for lack of stacktrace in exceptions thrown by states
5+
36
# [0.10.1-beta] - Feb 03, 2025
47
- Added a call to the ReplaceModelWithActiveModel method in BaseSubStateMachineState.SwitchModel to ensure the active model is set to the current model when switching models.
5-
-
8+
69
# [0.10.0-beta] - Jan 22, 2025
710
- Added a reference to the StateMachineController on each State. This removes the need to use GetComponent and allows for more direct
811
communication between states and the controller. This does introduce an issue where a StateMachine can become tightly coupled to a

Runtime/StateGraph/StateNodeModel.cs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Reflection;
5-
using Nonatomic.VSM2.Extensions;
6-
using Nonatomic.VSM2.Logging;
75
using Nonatomic.VSM2.NodeGraph;
8-
using Nonatomic.VSM2.Utils;
96
using UnityEngine;
107
using Object = UnityEngine.Object;
118

@@ -61,34 +58,32 @@ public void Enter(TransitionEventData eventData)
6158
var method = methods.FirstOrDefault(m =>
6259
m.GetParameters().Length == 1 &&
6360
m.GetParameters()[0].ParameterType == eventData.Type);
61+
62+
if (method == null) return;
6463

65-
if (method != null)
64+
try
65+
{
66+
method.Invoke(State, new[] { eventData.Value });
67+
}
68+
catch (Exception ex)
6669
{
67-
try
68-
{
69-
method.Invoke(State, new[] { eventData.Value });
70-
}
71-
catch (Exception ex)
72-
{
73-
Debug.LogError($"Error invoking OnEnter method: {ex.Message}");
74-
}
70+
Debug.LogException(ex);
7571
}
7672
}
7773
else
7874
{
7975
var method = methods.FirstOrDefault(m =>
8076
m.GetParameters().Length == 0);
77+
78+
if (method == null) return;
8179

82-
if (method != null)
80+
try
81+
{
82+
method.Invoke(State, null);
83+
}
84+
catch (Exception ex)
8385
{
84-
try
85-
{
86-
method.Invoke(State, null);
87-
}
88-
catch (Exception ex)
89-
{
90-
Debug.LogError($"Error invoking OnEnter method: {ex.Message}");
91-
}
86+
Debug.LogException(ex);
9287
}
9388
}
9489
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.nonatomic.visualstatemachinev2",
3-
"version": "0.10.1-beta",
3+
"version": "0.10.2-beta",
44
"displayName": "Visual State Machine V2",
55
"description": "Visual State Machine V2\n\nIMPORTANT NOTE: If you are upgrading to 0.9.0-beta and above from earlier versions, note that `OnEnter` methods now require an `[Enter]` attribute and that the base `OnEnter` method is no longer abstract but virtual.",
66
"unity": "2022.3",

0 commit comments

Comments
 (0)