Logs and raises an exception when registered callback expects more number of arguments when executed
556055
public function reportArgumentCountError()
    {
        $this->_logger->log(Logger::ERROR, "Problem calling notify callback.");
        $this->_errorHandler->handleError(
            new InvalidCallbackArgumentCountException('Registered callback expects more number of arguments than the actual number')
        );
    }
880967
function callHandler(callback, context, args) {
  switch (args.length) {
    case 0: return callback.call(context);
    case 1: return callback.call(context, args[0]);
    case 2: return callback.call(context, args[0], args[1]);
    case 3: return callback.call(context, args[0], args[1], args[2]);
    default: return callback.apply(context, args);
  }
}
866849
def enable_thread_logging(exception_callback=None):
    
    global logged_thread_enabled, Thread
    LoggedThread.exception_callback = exception_callback
    Thread = threading.Thread = LoggedThread
    logged_thread_enabled = True
604000
def execute_callback(callback, *args)
      (callback.arity == 2 ? callback.call(*args[0, 2]) : callback.call(*args)) if callback
    end
564438
def _run_callbacks(self):
        """"""
        for i in range(len(self._callbacks)):
            callback, args = self._callbacks.popleft()
            try:
                callback(*args)
            except Exception:
                self._log.exception('Ignoring exception in callback:')
1319183
def _call_method(self, request):
        """"""
        method = self.method_data[request['method']]['method']
        params = request['params']
        result = None
        try:
            if isinstance(params, list):
                # Does it have enough arguments?
                if len(params) < self._man_args(method):
                    raise InvalidParamsError('not enough arguments')
                # Does it have too many arguments?
                if not self._vargs(method) \
                        and len(params) > self._max_args(method):
                    raise InvalidParamsError('too many arguments')

                result = yield defer.maybeDeferred(method, *params)
            elif isinstance(params, dict):
                # Do not accept keyword arguments if the jsonrpc version is
                # not >=1.1.
                if request['jsonrpc'] < 11:
                    raise KeywordError

                result = yield defer.maybeDeferred(method, **params)
            else:  # No params
                result = yield defer.maybeDeferred(method)
        except JSONRPCError:
            raise
        except Exception:
            # Exception was raised inside the method.
            log.msg('Exception raised while invoking RPC method "{}".'.format(
                    request['method']))
            log.err()
            raise ServerError

        defer.returnValue(result)
833962
function expandErrors(logger) {
    var oldLogFunc = logger.log
    logger.log = function() {
      var args = Array.prototype.slice.call(arguments, 0)
      if (args.length >= 2 && args[1] instanceof Error) {
        args[1] = args[1].stack
      }
      return oldLogFunc.apply(this, args)
    };
    return logger
  }
80128
private void invokeIgnoreExceptions(Object obj, String method,
            Object... args) {
        try {
            invoke(obj, method, args);
        } catch (NoSuchMethodException e) {
            logger.trace("Unable to log progress", e);
        } catch (InvocationTargetException e) {
            logger.trace("Unable to log progress", e);
        } catch (IllegalAccessException e) {
            logger.trace("Unable to log progress", e);
        }
    }
447597
def exception_handler(self, ex):  # pylint: disable=no-self-use
        
        if isinstance(ex, CLIError):
            logger.error(ex)
        else:
            logger.exception(ex)
        return 1
713747
def raises(self, exception_type, function, *args, **kwargs):
        
        try:
            result = function(*args, **kwargs)
            self.log_error("{} did not throw exception {}".format(
                function.__name__,
                exception_type.__name__
            ), None)
            return result
        except Exception as e:
            if type(e) != exception_type:
                self.log_error("{} did raise {}: {}".format(
                    function.__name__,
                    type(e).__name__, e
                ), None)
304322
def _check_cb(cb_):
    '''
    
    '''
    if cb_ is not None:
        if hasattr(cb_, '__call__'):
            return cb_
        else:
            log.error('log_callback is not callable, ignoring')
    return lambda x: x
503057
def handle_rate_limit(func: Callable[[Any], Any], *args, **kwargs) -> Any:
    
    error_count = 0
    while True:
        try:
            return func(*args, **kwargs)
        except Exception as e:
            if error_count > 3:
                util_logger.error('Retried to call <{}> 3 times without success. '
                                  'Continuing without calling it.'.format(func.__name__))
                break

            if 'DELETED_COMMENT' in str(e):
                util_logger.warning('The comment has been deleted. '
                                    'Function <{}> was not executed.'.format(func.__name__))
                break
            wait = parse_wait_time(str(e))
            util_logger.error(e)
            util_logger.warning('Waiting ~{} minutes'.format(round(float(wait + 30) / 60)))
            time.sleep(wait + 30)
            error_count += 1
565101
function log() {
  if (typeof print === 'function') {
    print.apply(this, arguments)
  } else {
    console.log.apply(console, arguments)
  }
}
1198396
def _run_done_callbacks(self):
        ''' 
        '''
        with self._callbacks_lock:
            for callback in self._done_callbacks:
                try:
                    callback()
                # We do not want a callback interrupting the process, especially
                # in the failure cleanups. So log and catch, the excpetion.
                except Exception as ex:
                    logger.error("Exception: %s" % str(ex))
                    logger.error("Exception raised in %s." % callback, exc_info=True)

            self._done_callbacks = []
699346
function finallyCall(method)
{
  var l = arguments.length
  var params          = Sliced(arguments, 1, l - 3)
  var successCallback = arguments[l - 3]
  var errorCallback   = arguments[l - 2]
  var finallyCall     = arguments[l - 1]
  var finallyOk = function() {
    try {
      successCallback.apply(successCallback, arguments)
    } finally {
      finallyCall()
    }
  }
  var finallyErr = function() {
    try {
      errorCallback.apply(errorCallback, arguments)
    } finally {
      finallyCall()
    }
  }
  method.apply(method, params.concat(finallyOk, finallyErr))
}
757639
def call_many(self, callback, args):
        """"""
        if isinstance(callback, str):
            callback = getattr(self, callback)
        f = None
        for arg in args:
            f = callback(*arg)
        return f
881058
function callNormalizedCallback (callback, arg) {
        callback.fn.call(callback.scope, arg, callback.args);
    }