-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PermitIf == false should not trigger OnUnhandledTrigger exception. #412
Comments
I agree, this is annoying. If I find the time I might change the behaviour, but not in the near future. |
I disagree. Correct me if I am wrong, but how else can we know during runtime that a valid trigger was received but a guard condition failed? We use this feature extensively in our application where silently failing is not an option. |
Of course, there are many use cases, and many ways to use the library. If it's an requirement to keep track of failed guard condition, then the OnUnhandledTrigger event is very convenient. As a compromise, we could maybe add a OnGuardFailed in addition to OnUnhandledTrigger? One would fire if there are no transitions at all, and the other if there are no valid (i.e. all guards fail) transitions available. But I don't see this as the most important matter right now... |
That would be nice, but it would be a breaking change and I'm always wary of those. |
The compromise is a great idea but it does not solve my initial issue with the throw definition of said exception. If you declare any Permits it should not throw for the corresponding trigger regardless of the returning state of the guard. With a Permit they are handled, not unhandled as the exception suggest.. Best Regards |
I agree, the name of the exception is somewhat misleading, when the trigger has been "handled", but the guard function prevents the transition from completing. |
How about allowing to complement "PermitIf" with "IgnoreIf" mutually exclusive configurations?
|
Apparently, when the condition in
PermitIf
returns false and does not allow transition it throws an OnUnhandledTrigger exception.you can see this in my code here:
https://github.com/TybaIt/Blish-HUD-Modules/blob/5d1265dc5519263263bccd9b6f3c993cd67bb129/Music%20Mixer%20Module/Gw2StateService.cs#L153
The logs were getting spammed when the
_toggle
was false (and thus PermitIf didn't allow transition) by doing a switch case in the override ofOnUnhandledTrigger
The text was updated successfully, but these errors were encountered: