Don't recurse in error handling

94d3399c delayed exiting until after the request was fully handled to make
sure that clients see a proper error response. Combined with missing exception
handling this introduced the risk of recursive error handling if any aspect of
the HTTP handling threw an exception.

The tricky part is that we need to delay exiting so that an error response can
be sent asynchronously. At the same time we don't want pending event handlers
to fire any more, but currently don't have a clean way to tear them down.

This patch protects against recursion by wrapping the entire method in a
try/catch and unconditionally exits after the error is handled. It also works
around the document callback firing by wrapping sendRes in a try/catch block
to avoid triggering errorHandler via an uncaught exception.

We should find a generic solution to avoid recursive error handling, ideally
in the logger class. A possible solution is to refuse recursive calls in the
logger (return without output if attempted) and routing all error handling
through it.

Change-Id: I99ce55c09289fb070b872b21fd25239029cdc2f2