redding/sanford — pull request #41 by jcredding (2013-01-25 22:53:07+00:00)
Title: 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 response built
from the error and log messages that an error occurred, we now
handle exceptions raised when writing a response. This will trigger
Sanford's error handler and run only it's logic. In this case, we
don't want to trigger a user's logic because it's possible that
their error proc caused this fail. This is all trying to make sure
we respond with a valid response for any problems that occurred.