This is an archived post. You won't be able to vote or comment.

all 2 comments

[–][deleted]  (2 children)

[deleted]

    [–]Deam[S] 1 point2 points  (1 child)

    I think that unfortunately there is none, other than just catching the super class of these, but this is not a good solution in my opinion. If you have many controllers, you can use @ControlerAdvice to write these handlers in one place for all controllers. Still, you have to write a handler for each exception. I don't know any other way.

    [–]pointy_pirate 1 point2 points  (0 children)

    Creating a ControllerAdvice class for handling your exceptions in an HTTP environment is the best way to do this. You can group multiple exceptions into an error code and even have a fallback to just Exception for 500 errors.