Exception handle in spring web stream

Hello friends, I'm trying to process

org.springframework.webflow.execution.repository.snapshot.SnapshotNotFoundException

this is an exception but iam failed to do this. Thus, I am handling a SnapshotNotFoundException.

<transition on-exception="org.springframework.webflow.execution.repository.snapshot.SnapshotNotFoundException"
        to="exceptionHandler" />
+1
source share
1 answer

This declarative exception handling does not work for Web Flow internal exceptions. For this special case, we had to implement a custom one FlowHandler. handleException().

Sort of:

public class CustomFlowHandler extends AbstractFlowHandler
{
    @Override
    public String handleException(FlowException e, HttpServletRequest request,
            HttpServletResponse response)
    {
        if (e instanceof FlowExecutionRestorationFailureException)
        {
            if (e.getCause() instanceof SnapshotNotFoundException)
            {
                // TODO return the desired location string. See javadoc for options
                return "serverRelative:/missingSnapshot.html";
            }
        }
        return super.handleException(e, request, response);
    }
}

And in the Spring configuration file:

<!-- custom flow handler -->
<bean name="your-flow-name" class="yourpackage.CustomFlowHandler"/>
+4
source

Source: https://habr.com/ru/post/1545182/


All Articles