Wraps a try-catch handler around the handler.

@param {function} handler
@param {*} args
763351
function tryWrapper(handler) {
    for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
        args[_key - 1] = arguments[_key];
    }

    try {
        handler.apply(undefined, args);
    } catch (err) {
        console.error("handler received an error: " + err.message + ", " + JSON.stringify(err));
    }
}
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);
}
181399
def set_handler(self, handler):
        
        if self._handler:
            raise Exception('Handler was already set')
        if handler:
            self._handler = async_task(handler, loop=self._loop)
700288
public function callHandler($handler_id, $method, array $args)
    {
        try {
            $handlers = $this->getHandlers();
            return Handler::call($handlers, $handler_id, $method, $args);
        } catch (Exception $ex) {
            return null;
        }
    }
524568
function ExitHandler( exiting, error ) {
	if( error ) {
		if( error.stack ) {
			console.error( error.stack );
		}

		process.exit( 1 );
	}

	if( exiting.now ) {
		process.exit( 0 ); // exit now
	}

	console.log('\n');

	process.exit( 0 ); // now exit with a smile :)
}
264323
function handler(responseCode, data, ioArgs) {
                    that.xhr = ioArgs.xhr;
                    that.statusCode = that.xhr && !that.xhr.timedOut && that.xhr.status || 0;
                    if (that.canceled) {
                        logger.debug("Request [" + that.id + "] was canceled, not calling handler");
                    } else {
                        that.pending = false;
                        that.complete = true;
                        paramHandler(responseCode, data, ioArgs);
                    }
                }
524049
def bind(self, handler, argspec):
        
        self.handlers[argspec.key].append((handler, argspec))
761182
@Override
  public void registerErrorHandler(final EventHandler<Exception> handler) {
    this.clientEventListener.registerErrorHandler(handler);
    this.serverEventListener.registerErrorHandler(handler);
  }
1081880
function invoke(target, method, args, ignore) {

  if (method === undefined) {
    method = target;
    target = undefined;
  }

  if ('string' === typeof method) { method = target[method]; }
  if (args && ignore > 0) {
    args = args.length > ignore ? slice.call(args, ignore) : null;
  }

  // Unfortunately in some browsers we lose the backtrace if we rethrow the existing error,
  // so in the event that we don't have an `onerror` handler we don't wrap in a try/catch
  if ('function' === typeof Ember.onerror) {
    try {
      // IE8's Function.prototype.apply doesn't accept undefined/null arguments.
      return method.apply(target || this, args || []);
    } catch (error) {
      Ember.onerror(error);
    }
  } else {
    // IE8's Function.prototype.apply doesn't accept undefined/null arguments.
    return method.apply(target || this, args || []);
  }
}
743952
function(type, event, handler) {
        _.parsers.forEach(function(parser) {
            type = type.replace(parser[0], function() {
                var args = _.slice(arguments, 1);
                args.unshift(event, handler);
                return parser[1].apply(event, args) || '';
            });
        });
        return type ? event.type = type : type;
    }
167561
function(args, callInstance) {
    handlers.afterFunc({name: callInstance.name}, null, args, callInstance);
  }
351813
protected HttpHandler wrapWithDispatcher(final HttpHandler handler) {
        return new HttpHandler() {
            public void handleRequest(HttpServerExchange exchange) throws Exception {
                if (exchange.isInIoThread()) {
                    exchange.dispatch(handler);
                } else {
                    handler.handleRequest(exchange);
                }
            }
        };
    }
1025411
function tryCatchNextTick(object, method, args) {
  try {
    return method.apply(object, args);
  } catch (error) {
    process.nextTick(function () {
      throw error;
    });
  }
}
1299970
function wrapRequestHandler(func) {
  return function handler(req, res, next) {
    try {
      const result = func(req, res, next)
      if (result && result.catch) result.catch(e => next(e))
    } catch(e) {
      next(e)
    }
  }
}
323078
function( type, handler ) {

      if( handler === void 0 || handler === null )
        throw new Error( 'Missing argument "handler"' )

      if( typeof handler !== 'function' && typeof handler.handleEvent !== 'function' )
        throw new TypeError( 'Handler must be a function.' )

      this._events[ type ] ?
        this._events[ type ].push( handler ) :
        this._events[ type ] = [ handler ]

      if( Emitter.warn && this._events[ type ].length > this._maxListeners ) {
        if( this._maxListeners > 0 && !this._memLeakDetected ) {
          this._memLeakDetected = true
          console.warn(
            'WARNING: Possible event emitter memory leak detected.',
            this._events[ type ].length, 'event handlers added.',
            'Use emitter.setMaxListeners() to increase the threshold.'
          )
          console.trace()
        }
      }

      return this

    }
700
public function to($handler /*, $args… */)
    {
        $args = array_slice(func_get_args(), 1);

        return $this->then(
            function (Allocation $allocation) use ($handler, $args) {
                try {
                    $result = call_user_func_array($handler, $args);
                    $result = \React\Promise\resolve($result);
                    $result->then(array($allocation, 'releaseAll'), array($allocation, 'releaseAll'));
                } catch (\Exception $e) {
                    $result = new RejectedPromise($e);
                    $allocation->releaseAll();
                }

                return $result;
            }
        );
    }
1284160
function listenExit(handler) {
  const onSighup = () => {
    process.exit(1 | 0x80);
  };

  const onSigint = () => {
    process.exit(2 | 0x80);
  };

  const onSigterm = () => {
    process.exit(15 | 0x80);
  };

  const onError = (err) => {
    if (err && err.stack)
      console.error(String(err.stack));
    else
      console.error(String(err));

    process.exit(1);
  };

  process.once('exit', handler);

  if (process.listenerCount('SIGHUP') === 0)
    process.once('SIGHUP', onSighup);

  if (process.listenerCount('SIGINT') === 0)
    process.once('SIGINT', onSigint);

  if (process.listenerCount('SIGTERM') === 0)
    process.once('SIGTERM', onSigterm);

  if (process.listenerCount('uncaughtException') === 0)
    process.once('uncaughtException', onError);

  process.on('newListener', (name) => {
    switch (name) {
      case 'SIGHUP':
        process.removeListener(name, onSighup);
        break;
      case 'SIGINT':
        process.removeListener(name, onSigint);
        break;
      case 'SIGTERM':
        process.removeListener(name, onSigterm);
        break;
      case 'uncaughtException':
        process.removeListener(name, onError);
        break;
    }
  });
}