Fix bug on error handler