Create a route handler wrapper to call success or error.
976682
function(req, res) {
        if (res.locals.success) {
            options.success(model, response);
        } else {
            options.error(model, response);
        }
    }
462187
def _handle_request(self, msg_id, method, params):
        """"""
        try:
            handler = self._dispatcher[method]
        except KeyError:
            raise JsonRpcMethodNotFound.of(method)

        handler_result = handler(params)

        if callable(handler_result):
            log.debug("Executing async request handler %s", handler_result)
            request_future = self._executor_service.submit(handler_result)
            self._client_request_futures[msg_id] = request_future
            request_future.add_done_callback(self._request_callback(msg_id))
        else:
            log.debug("Got result from synchronous request handler: %s", handler_result)
            self._consumer({
                'jsonrpc': JSONRPC_VERSION,
                'id': msg_id,
                'result': handler_result
            })
60594
def _wrapper(self):
        
        try:
            res = self.func(*self.args, **self.kw)
        except Exception as e:
            self.mediator.set_error(e)
        else:
            self.mediator.set_result(res)
631761
def register_route(http_method, path, callback, options)
      route = new_route(http_method, path, callback, options)
      route.to(HTTPCallback.new(handler_class, callback))
      handler_class.http_routes << route
    end
1043621
function invokeHTTPHandler(handler, args, req, res, done) {
  // inject parsed parameters into request
  req.params = args;
  // call handler with typical HTTP request/response parameters
  let result = handler(req, res);
  // handle results that are not a trusted Promise with Promise.resolve()
  // which also supports other then-ables
  if (result instanceof Promise === false) {
    result = Promise.resolve(result);
  }
  return result.then(() => done()).catch(done);
}
708283
function registerRoute(method, path, handlers) {
        //Our handlers return a promise, restify uses a `next` callback isntead.
        var restifyHandlers = handlers.map(function(handler) {
            //Replace empty entries with the default handler.
            if (!handler) {
                return defaultHandler.bind(this, path);
            }
            //Turn the handler into a restify handler.
            return toRestifyHandler.call(this, handler);
        }, this);
        //If no handler was specified, add the default one.
        if (!restifyHandlers.length) {
            restifyHandlers.push(defaultHandler.bind(this, path));
        }
        server[method](path, restifyHandlers);
    }
963211
def _result_handler(self, response: Dict[str, Any]):
        
        res = response.get("MESSAGE")
        result = res.get("RESULT")
        return result
868802
function route(method, path, handler, config) {

    if( (typeof method !== 'string' && !Array.isArray(method))
        || (typeof path !== 'string')
        || (typeof handler !== 'function' && typeof handler !== 'string' && typeof handler !== 'object')
        || (config != null && typeof config !== 'object') ) {
        throw new TypeError('Bad arguments');
    }

    if (typeof method === 'string') {
        method = method.toUpperCase().replace(/\s+/g, ' ').trim().replace(/^DEL$/, 'DELETE');
        if (method.match(/ /)) {
            method = method.split(' ');
        }
    }
    if (Array.isArray(method)) {
        method = method.map(function (x) {
            return x.toUpperCase().replace(/\s+/g, ' ').trim().replace(/^DEL$/, 'DELETE');
        });
        method.forEach(function (elem) {
            if (elem.match(/[^A-Z*]/)) {
                throw new TypeError('Bad arguments');
            }
        });
    }
    return {
        method: method,
        path: path,
        handler: handler,
        config: config
    };
}
243432
def __handler(self, connection, event):
        
        try:
            # Find local handler
            method = getattr(self, "on_{0}".format(event.type))
        except AttributeError:
            pass
        else:
            try:
                # Call it
                return method(connection, event)
            except Exception as ex:
                logging.exception("Error calling handler: %s", ex)
5678
def make_wrapper(self, callable_):
        """"""
        assert callable(callable_)
        def wrapper(*args, **kw):
            return self.call_and_report_errors(callable_, *args, **kw)
        return wrapper
1132615
function handle(route, file) {
  route.status = 'starting';
  route.emit('handle', file);

  for (let layer of route.stack) {
    route.emit('layer', layer, file);
    layer.handle(file);
  }

  route.status = 'finished';
  route.emit('handle', file);
  return file;
}
314458
def _raise_error_routes(iface, option, expected):
    '''
    
    '''
    msg = _error_msg_routes(iface, option, expected)
    log.error(msg)
    raise AttributeError(msg)
145696
function _handleResult(callback, err, res) {
    return callback(null, {
        error:  err,
        result: res
    });
}
1258715
def handle(self):
        """"""
        rv = None
        try:
            rv = BaseHTTPRequestHandler.handle(self)
        except (_ConnectionError, socket.timeout) as e:
            self.connection_dropped(e)
        except Exception as e:
            if self.server.ssl_context is None or not is_ssl_error(e):
                raise
        if self.server.shutdown_signal:
            self.initiate_shutdown()
        return rv
1305971
def register(self, method, uri, call_back):
        
        found = False

        self.create_route(uri, False)
        self.routes[uri]['handlers'].register_method(method,
                                                     call_back)
454606
def add_handler(self, handler):
        """"""
        if not callable(handler):
            raise TypeError("'%s' is not callable." % handler)

        self.append(handler)
744934
def handle_action(self, channel, nick, msg):
		""

		messages = ()
		for handler in Handler.find_matching(msg, channel):
			exception_handler = functools.partial(
				self._handle_exception,
				handler=handler,
			)
			rest = handler.process(msg)
			client = connection = event = None
			# for regexp handlers
			match = rest
			f = handler.attach(locals())
			results = pmxbot.itertools.generate_results(f)
			clean_results = pmxbot.itertools.trap_exceptions(results, exception_handler)
			messages = itertools.chain(messages, clean_results)
			if not handler.allow_chain:
				break
		self._handle_output(channel, messages)