Add ability to set an error handler

Hi,

I was having a lot of timeouts and sigterms and was getting annoying so I've added a way to include an error handler. I updated the readme so you can see how it behaves.

Let me know what you think! In the meantime I'll use my fork.

Cheers