Added exception handling for deferreds

Previously, the deferred detection would make it impossible for a subclass of `Dispatcher` to attach its own errbacks to the deferred.  This is mainly important for the sake of catching unexpected exceptions and making sure the HTTP response always gets written + finished.

To make the uncaught exception cases better, I ported over this code I was previously using in a subclass of `Dispatcher`.