patch error handler