Jun 29th, 2011, 11:22 AM
Changing Exit Status description on Failure
I am trying to figure out how I can add a custom exit desciption to the Exit Status on step failure. I don't want to append to the stacktrace that gets put in there by default. I want to replace the stack track with more a more informative error message, so I can easily view in the Spring Batch Admin console. Any suggestions?
Jul 1st, 2011, 06:07 AM
I'm pretty sure AbstractStep is designed to only append to the ExitStatus description, so you either have to use a different Step implementation (tricky) or try and get hold of the error before the stack trace is appended so your message comes first. Depending on the structure of your step you could do that in a custom Tasklet or one of the *Listener interfaces (but not StepExecutionListener beacsue the callback comes too late). I think as long as you use TaskletStep, you can add an ExceptionHandler (or a stepOperations with RepeatListener) in a parent step and that will always get the callback before the AbstractStep gets a chance to catch the exception.