add an error handler

fixes #51