rewrited error handler