You're confusing things a bit I think.
This handles Java exceptions, which shoud actually take care of your 50X issues because those are problems server side. 40x can be different (401, 402). Are you saying you want to redirect to a different location?
Yes you're right, I'm confused
I did not really think about wether to redirect 40x to different locations as 50x. But that would make sense!
Anyway I don't know how to catch on 40x.