Catch exceptions when writing the response

This fixes exceptions that occur when a response's hash is trying
to be written to a socket. In particular, BSON converting a hash
can raise a number of exceptions. To ensure we get a error
response and that the exception is logged, we now handle exceptions
raised when writing a response. This will trigger Sanford's error
handler and only it's logic (no user logic) for generating a
response.