bug fix and add logger in error handler.