Manual:$wgExceptionHooks

Details
Hooks that are used for outputting exceptions.

Format is:

or:

Hooks receive the exception object as their first argument and should return strings or false.