Manual:$wgExceptionHooks

Details
Hooks that are used for outputting exceptions. Format is: or:

Hooks should return strings or false.