Registers a handler for requests, responses and/or exceptions

 @param [Class] klass
352167
def use(klass, *args, &block)
      request_handler   = "#{klass.name}::RequestHandler".safe_constantize
      response_handler  = "#{klass.name}::ResponseHandler".safe_constantize
      exception_handler = "#{klass.name}::ExceptionHandler".safe_constantize

      request_handlers   << request_handler.new(*args, &block) if request_handler
      response_handlers  << response_handler.new(*args, &block) if response_handler
      exception_handlers << exception_handler.new(*args, &block) if exception_handler
    end
733132
public static void register(Class<?> clazz) {
    for (Method m : clazz.getDeclaredMethods()) {
      EngineFunction func = m.getAnnotation(EngineFunction.class);
      if (func != null) {
        EngineHandlerInfo info = EngineHandlerInfo.getEngineHandlerInfo(m, func);
        if (info != null) {

          funcs.put(info.getEndPoint(), info);
        }
        continue;
      }
      EngineHook hook = m.getAnnotation(EngineHook.class);
      if (hook != null) {
        EngineHandlerInfo info = EngineHandlerInfo.getEngineHandlerInfo(m, hook);
        if (info != null) {
          funcs.put(info.getEndPoint(), info);
        }
      }

      IMHook imHook = m.getAnnotation(IMHook.class);
      if (imHook != null) {
        EngineHandlerInfo info = EngineHandlerInfo.getEngineHandlerInfo(m, imHook);
        if (info != null) {
          funcs.put(info.getEndPoint(), info);
        }
      }
    }
  }
472734
def _construct_error_handling(self):
        
        self._app.register_error_handler(500, LambdaErrorResponses.generic_service_exception)
        self._app.register_error_handler(404, LambdaErrorResponses.generic_path_not_found)
        self._app.register_error_handler(405, LambdaErrorResponses.generic_method_not_allowed)
1374214
def _create_handler(self, handler_class, level):
        """"""
        if handler_class == logging.StreamHandler:
            handler = handler_class()
            handler.setLevel(level)
        elif handler_class == logging.handlers.SysLogHandler:
            handler = handler_class(address='/dev/log')
            handler.setLevel(level)
        elif handler_class == logging.handlers.TimedRotatingFileHandler:
            handler = handler_class(self.filename, when='midnight')
            handler.setLevel(level)
        elif handler_class == AlkiviEmailHandler:
            handler = handler_class(mailhost='127.0.0.1',
                                    fromaddr="%s@%s" % (USER, HOST),
                                    toaddrs=self.emails,
                                    level=self.min_log_level_to_mail)
            # Needed, we want all logs to go there
            handler.setLevel(0)

        formatter = self.get_formatter(handler)
        handler.setFormatter(formatter)
        self.handlers.append(handler)
        self.logger.addHandler(handler)
1191174
def register_inheritance_handler
      synchronize do

        return if defined?(Object.inherited_with_lumber_registry)

        Object.class_eval do

          class << self

            def inherited_with_lumber_registry(subclass)
              inherited_without_lumber_registry(subclass)

              # Add a logger to 'subclass' if it is directly in the registry
              # No need to check full inheritance chain LoggerSupport handles it
              # Also prevent rails from subsequently overriding our logger when rails
              # is loaded after registering logger inheritance
              if Lumber::InheritanceRegistry[subclass.name]
                subclass.send(:include, Lumber.logger_concern)
              end
            end

            alias_method_chain :inherited, :lumber_registry

          end

        end

      end
    end
357641
public static void registerMessageHandler(Class<? extends AVIMMessage> clazz,
                                            MessageHandler<?> handler) {
    Set<MessageHandler> handlerSet = new CopyOnWriteArraySet<>();

    Set<MessageHandler> set = messageHandlerRepository.putIfAbsent(clazz, handlerSet);
    if (set != null) {
      handlerSet = set;
    }
    handlerSet.add(handler);
  }
1036879
def register(klass):
    ""
    logger.info("registering {}".format(klass.__name__))
    AGNOCOMPLETE_REGISTRY[klass.slug] = klass
43205
def CATCH(exception_klass, &block)
      block.call
    rescue ::Exception
      if $!.instance_of? exception_klass
        pass
      else
        failure("Faced a exception, that instance of #{exception_klass}.",
                "Faced a exception, that instance of #{$!.class}.", 2)
      end
    else
      failure("Faced a exception, that instance of #{exception_klass}.",
              'The block was not faced any exceptions.', 2)
    ensure
      _declared!
    end
1087199
def register(self, request_class: Request, mapper_func: Callable[[Request], BrightsideMessage]) -> None:
        

        key = request_class.__name__
        if key not in self._registry:
            self._registry[key] = mapper_func
        else:
            raise ConfigurationException("There is already a message mapper defined for this key; there can be only one")
396045
def call(env)
      handler = self.class.build(env)
      handler.call(env)
    rescue => e
      self.class.handle_error(e)
    end
1294770
def handle_request(self, msgtype, msgid, method, args, kwargs):
        """"""
        response = None
        error = None
        exception = None

        try:
            response = self.dispatch.call(method, args, kwargs)
        except Exception as e:
            error = (e.__class__.__name__, str(e))
            exception = e

        if isinstance(response, Deferred):
            response.add_callback(self.send_response, msgid)
            response.add_errback(self.send_error, msgid)
        else:
            if exception is None:
                self.send_response(msgid, response)
            else:
                self.send_error(msgid, exception)
696038
protected function registerErrorHandle(): void
    {
        \set_error_handler([$this, 'handleError']);
        \set_exception_handler([$this, 'handleException']);
        \register_shutdown_function(function () {
            if ($e = \error_get_last()) {
                $this->handleError($e['type'], $e['message'], $e['file'], $e['line']);
            }
        });
    }
129035
def define(self, klass, name="default"):
        

        def decorate(func):
            @wraps(func)
            def wrapped(*args, **kwargs):
                return func(*args, **kwargs)

            self.register(klass, func, name=name)

            return wrapped

        return decorate
943694
static void register(Class<? extends URLStreamHandler> handlerClass) {
    checkArgument("Handler".equals(handlerClass.getSimpleName()));

    String pkg = handlerClass.getPackage().getName();
    int lastDot = pkg.lastIndexOf('.');
    checkArgument(lastDot > 0, "package for Handler (%s) must have a parent package", pkg);

    String parentPackage = pkg.substring(0, lastDot);

    String packages = System.getProperty(JAVA_PROTOCOL_HANDLER_PACKAGES);
    if (packages == null) {
      packages = parentPackage;
    } else {
      packages += "|" + parentPackage;
    }
    System.setProperty(JAVA_PROTOCOL_HANDLER_PACKAGES, packages);
  }
243539
def _generate_request_handler_proxy(handler_class, handler_args, name):
    """"""

    @scope.inject
    def request_handler_wrapper(app, handler, **kwargs):
        handler = handler_class(app, handler.request, **handler_args)
        handler._execute([], **kwargs)
    request_handler_wrapper.__name__ = name
    request_handler_wrapper.handler_class = handler_class
    request_handler_wrapper.handler_args = handler_args

    return request_handler_wrapper
245507
protected function registerRequestCallback()
    {
        $this->swoolePort->on('Request', function ($request, $response) {
            $this->dispatchEvent('Request', $this->server, $this, $request, $response);
        });
    }
38438
def register_handler(alias: str, handler: callable):
        
        if SignalDispatcher.handlers.get(alias) is None:
            SignalDispatcher.handlers[alias] = [handler]
        else:
            SignalDispatcher.handlers.get(alias).append(handler)