refactored ErrorHandler.