<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def on_error(self, namespace=None):
 """Decorator to define a custom error handler for SocketIO events. This decorator can be applied to a function that acts as an error handler for a namespace. This handler will be invoked when a SocketIO event handler raises an exception. The handler function must accept one argument, which is the exception raised. Example:: @socketio.on_error(namespace='/chat') def chat_error_handler(e):
 print('An error has occurred: ' + str(e)) :param namespace: The namespace for which to register the error handler. Defaults to the global namespace. """

        namespace = namespace or '/'

        def decorator(exception_handler):
            if not callable(exception_handler):
                raise ValueError('exception_handler must be callable')
            self.exception_handlers[namespace] = exception_handler
            return exception_handler
        return decorator