Attach error handler.