adding on_error handler for exeception logging.