-
Notifications
You must be signed in to change notification settings - Fork 618
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
Not able to catch and rethrow spring state machine error #553
Comments
None of these would not work as any user level interaction cannot break machine. Can't you just check from |
@jvalkeal one unusal behaviour on similar lines. I have spring security configured. And my transition has security enabled. If a wrong role tries to do a transition , it logs AccessDeniedException.However it does not throw that exception
This is the exception being thrown
However i went ahead and looked into the code .Its just logging it but not being thrown
Can you help me how can i handle such scenraiors |
Well security integration is designed to work internally effectively denying transitions. In this case it breaks from a loop if you follow logic around those lines. |
@jvalkeal How do I catch this error if it isn't being rethrown? Should I just check if |
But, we need to know why transition is denied. The reason is only accessible in the log. We got to indicate to the final user why the machine is still une the same state. |
@jvalkeal |
We can set statemachine error using machine.setStateMachineError(new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "XXX")); i.e machine.sendEvent(event); |
I am working on a project that deals with a contract workflow. I want the state machine to throw an error if a wrong event is sent. I tried using listener to catch the exception thrown by state machine as given in the documentation but I am not able to rethrow error to show an exception message.
Here is my listener
Here is the state machine configuration where I registered the listener.
Here is the stack trace obtained after throwing custom exception from the listener.
I've also tried putting a try-catch block around
sendEvent
method but it doesn't come inside the catch block.Please tell what approach should I take to catch state machine errors to rethrow them and perform some logic.
The text was updated successfully, but these errors were encountered: