Create a runtime exception from an RPC Error Code.

@param int $error_no The RPC error code.
@param string $package The package name of the RPC call.
@param string $call The call name of the RPC call.
190590
private static function getRpcErrorFromException($error_no, $package, $call) {
    if (isset(self::$exceptionLookupTable[$error_no])) {
      $res = self::$exceptionLookupTable[$error_no];
      return new $res[0](sprintf($res[1], $package, $call));
    }
    return new RPCFailedError(sprintf('Remote implementation for %s.%s failed',
                                       $package,
                                       $call));
  }
853533
public function error($error,$errstr, $errfile=null, $errline=null, $errcontext=null){
        //错误捕获
        $e = new \ErrorException($errstr, $error, $error, $errfile, $errline);
        $this->dowith($e);

    }
905946
public static function ExceptionErrorHandler($errno = 0, $errstr = null, $errfile = null, $errline = null)
    {
        // If error is suppressed with @, don't throw an exception
        if (error_reporting() === 0 || strpos($errstr, 'headers already sent') || ($errfile && strpos($errfile, 'vendor/amphp') !== false)) {
            return false;
        }

        throw new self($errstr, $errno, null, $errfile, $errline);
    }
777391
protected function triggerError($msg, $no) {
        // determine previous stack frame
        $backtrace = debug_backtrace();
        if ($this->chatty && isset($backtrace[1])) {
            $frame = $backtrace[1];
            $extra = " on line {$frame['line']} in file {$frame['file']}";
        } else {
            $extra = '';
        }
        trigger_error($msg . $extra, $no);
    }
12684
public function php_error_handler($errno, $errstr, $errfile, $errline)
    {
        $e = new \Exception($errstr, $errno);
        call_user_func($this->error50x, $e);
    }
544732
public function error($key = null, $return_error = null, $return_no_error = '')
    {
        if (isset($key)) {
            $result = gplcart_array_get($this->errors, $key);
        } else {
            $result = empty($this->errors) ? null : $this->errors;
        }

        if (isset($result)) {
            return isset($return_error) ? $return_error : $result;
        }

        return $return_no_error;
    }
750320
public function error($argument = null)
    {
        if (is_callable($argument)) {
            return parent::error($argument);
        } else {
            if (isset($this->container['response'])) {
                try {
                    return parent::error($argument);
                } catch (\Slim\Exception\Stop $e) {
                    // noop
                }
            } else {
                $this->callErrorHandler($argument);
                // noop
            }
        }
    }
694030
public function handleRpcErrors($error)
    {
        switch ($error['code']) {
            case -32600:
                throw new \InvalidArgumentException('Invalid Request: '. $error['message']);
            case -32601:
                throw new \BadFunctionCallException('Procedure not found: '. $error['message']);
            case -32602:
                throw new \InvalidArgumentException('Invalid arguments: '. $error['message']);
            case -32603:
                throw new \RuntimeException('Internal Error: '. $error['message']);
            default:
                throw new \RuntimeException('Invalid request/response: '. $error['message'], $error['code']);
        }
    }
52888
protected function Crash($errmsg = "Unknown Error", $code = 0, $exception = null)
	{
		$ex = $exception ? $exception : new Exception($errmsg, $code);
		throw $ex;
	}
1314145
function noerror(/*...*/) { // function can be referenced within each task as this.noerror
            try { tasks.length ? tasks.shift().apply(funcs[0], arguments) : next.apply(this, [null].concat(Array.prototype.slice.call(arguments))) }
            catch (ex) { next(ex) } // return any thrown exception as the argument to next()
        }
580376
public static function errorHandler($errno, $errstr, $errfile, $errline)
    {
        throw new KernelException($errno . ': ' . $errstr . '[' . $errfile . ' (' . $errline . ')]');
    }
876486
public function errorHandler($errno, $errstr, $errfile, $errline) {
        $error = sprintf("[%d] (%s)", $errno, $errstr);

        switch ($errno) {
            case E_USER_NOTICE:
                $this->addError($error, $errfile, $errline, ERROR_ERROR, LOG_ERROR);
                break;

            case E_USER_WARNING:
                $this->addError($error, $errfile, $errline, ERROR_ERROR, LOG_ERROR);
                break;

            case E_WARNING:
                $this->addError($error, $errfile, $errline, ERROR_ERROR, LOG_ERROR);
                break;

            case E_USER_ERROR:
                $this->addError($error, $errfile, $errline, ERROR_ERROR, LOG_SYSTEM);
                break;

            default:
                $this->addError($error, $errfile, $errline, ERROR_ERROR, LOG_ERROR);
                break;
        }
    }
188661
private static function _specificAPIError($rbody, $rcode, $rheaders, $resp, $errorData)
    {
        $msg = isset($errorData['message']) ? $errorData['message'] : null;
        $param = isset($errorData['param']) ? $errorData['param'] : null;
        $code = isset($errorData['code']) ? $errorData['code'] : null;
        $type = isset($errorData['type']) ? $errorData['type'] : null;

        switch ($rcode) {
            case 400:
                // 'rate_limit' code is deprecated, but left here for backwards compatibility
                // for API versions earlier than 2015-09-08
                if ($code == 'rate_limit') {
                    return new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders);
                }
                if ($type == 'idempotency_error') {
                    return new Error\Idempotency($msg, $rcode, $rbody, $resp, $rheaders);
                }

                // intentional fall-through
            case 404:
                return new Error\InvalidRequest($msg, $param, $rcode, $rbody, $resp, $rheaders);
            case 401:
                return new Error\Authentication($msg, $rcode, $rbody, $resp, $rheaders);
            case 402:
                return new Error\Card($msg, $param, $code, $rcode, $rbody, $resp, $rheaders);
            case 403:
                return new Error\Permission($msg, $rcode, $rbody, $resp, $rheaders);
            case 429:
                return new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders);
            default:
                return new Error\Api($msg, $rcode, $rbody, $resp, $rheaders);
        }
    }
1127710
public static function err($cx, $err) {
        if ($cx['flags']['debug'] & static::DEBUG_ERROR_LOG) {
            error_log($err);
            return;
        }
        if ($cx['flags']['debug'] & static::DEBUG_ERROR_EXCEPTION) {
            throw new \Exception($err);
        }
    }
1275955
public function createErrorResponse(\Exception $exception, JsonRpcRequest $fromRequest = null) : JsonRpcResponse
    {
        return $this->createEmptyResponse($fromRequest)
            ->setError(
                $exception instanceof JsonRpcExceptionInterface
                    ? $exception
                    : new JsonRpcInternalErrorException($exception)
            )
        ;
    }
320715
public static function errorToException($errno, $errstr, $errfile, $errline)
    {
        $exclude = E_STRICT | E_NOTICE | E_USER_NOTICE;
        if (((error_reporting() & $errno) != $errno) || (($exclude & $errno) == $errno)) {
            return false;
        }

        $constants = get_defined_constants(true);
        $name = 'Unknown PHP Error (' . $errno . ')';
        foreach ($constants['Core'] as $c => $value) {
            if ((substr($c, 0, 2) != 'E_') || ($value != $errno)) {
                continue;
            }

            $name = 'PHP ' . ucwords(str_replace('_', ' ', strtolower(substr($c, 2))));
        }

        $exception = new \RuntimeException(sprintf('%s: %s in %s on line %d', $name, $errstr, $errfile, $errline), $errno);

        // Impossible to throw an exception without stack trace
        // happens when errors occour in shutdown scope (i.e. serialize handler)
        if (count($exception->getTrace()) < 1) {
            return false;
        }

        throw $exception;
    }
226345
public static function error_handler($errno, $errstr, $errfile, $errline)
    {
        self::flush(true);

        $response = PheryResponse::factory()->exception($errstr, array(
            'code' => $errno,
            'file' => self::$expose_paths ? $errfile : pathinfo($errfile, PATHINFO_BASENAME),
            'line' => $errline
        ));

        self::respond($response);
        self::shutdown_handler(false, true);
    }