Helper method to create a JSON error.

@param int $errno An error number from json_last_error()

@return void
168295
private static function handleJsonError($errno)
    {
        $messages = array(
            JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
            JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON',
            JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
            JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON',
            JSON_ERROR_UTF8 => 'Malformed UTF-8 characters' //PHP >= 5.3.3
        );
        static::ReturnJson(isset($messages[$errno])
            ? $messages[$errno]
            : 'Unknown JSON error: ' . $errno);
    }
276454
static public function errorHandler($errno, $errstr, $errfile='', $errline=0, $errcontext=array())
    {
        if (!isset(self::$ignore[basename($errfile) . '-' . $errline . '-' . $errno])) {
            $msg = $errstr . ' Line '
                    . $errline
                    . ', '
                    . $errfile;
            self::$logger->debug($msg);
        }

        return true;
    }
201135
static public function appError($errno, $errstr, $errfile, $errline) {
      switch ($errno) {
          case E_ERROR:
          case E_PARSE:
          case E_CORE_ERROR:
          case E_COMPILE_ERROR:
          case E_USER_ERROR:
            ob_end_clean();
            $errorStr = "$errstr ".$errfile." 第 $errline 行.";
            if(C('LOG_RECORD')) Log::write("[$errno] ".$errorStr,Log::ERR);
            self::halt($errorStr);
            break;
          default:
            $errorStr = "[$errno] $errstr ".$errfile." 第 $errline 行.";
            self::trace($errorStr,'','NOTIC');
            break;
      }
    }
766821
public static function checkLastError()
    {
        $error = json_last_error();

        if ($error == JSON_ERROR_NONE) {
            return;
        }

        $message = json_last_error_msg();

        throw new JsonException("JSON Error: " . $message, $error);
    }
1188814
private function add_error_object(\alsvanzelf\jsonapi\error $error) {
	$error_response_part = $error->get_array();
	$error_http_status   = $error->get_http_status();
	
	$this->errors_collection[] = $error_response_part;
	if ($error_http_status) {
		$this->set_http_status($error_http_status);
	}
}
1310495
public static function error($errno, $errstr, $errfile = '', $errline = 0, $errcontext = [])
    {
        $exception = new Exception($errno, $errstr, $errfile, $errline, $errcontext);

        if (error_reporting() & $errno) {
            throw $exception;
        }
    }
1147819
public function trapXMLError($errno, $errstr, $errfile, $errline)
    {
        $this->__error($errno, str_replace('DOMDocument::', null, $errstr), $errfile, $errline, 'xml');
    }
314050
public function error($errno, $error, $file, $line) {
        try {
            throw new MyException($error, $errno, $file, $line);
        } catch (MyException $e) {
            ERRORCODE($e);
        }
    }
1191924
public function error($errno, $errstr)
    {
        if ($errno === E_RECOVERABLE_ERROR) {
            $name = $this->getName();
            $route = $name ? $name : $this->getActionName();
            throw new CatchableFatalErrorException($route, $errstr);
        }
    }
1075156
private function handleCurlError($error, $errno)
    {
        switch ($errno) {
            case CURLE_COULDNT_CONNECT:
            case CURLE_COULDNT_RESOLVE_HOST:
            case CURLE_OPERATION_TIMEOUTED:
                $msg = "Could not connect to Yandex Money API. Please check your internet connection and try again.";
                break;
            case CURLE_SSL_CACERT:
            case CURLE_SSL_PEER_CERTIFICATE:
                $msg = "Could not verify SSL certificate.";
                break;
            default:
                $msg = "Unexpected error communicating.";
        }
        $msg .= "\n\n(Network error [errno $errno]: $error)";
        throw new ApiConnectionException($msg);
    }
1226203
public function customErrorHandler($errno, $errstr) {
		if ($this->_isActive('phpException')) {
			$check = 'phpException';
			$level = $this->_config->getTestLevel($check);
			if ($level === null) {
				$level = WARNING;
			}
			$message = $this->_getMessage('PHP_EXPCEPTION', $errstr);

			$this->_writeError($check, $message, $this->lineNumber, $level);
		}

		/* Don't execute PHP internal error handler */
		return false;
	}
295643
public function jsonError($errorCode, $errorMessage = null)
    {
        // Build error from message
        $error = [
            'type' => 'error',
            'code' => $errorCode,
        ];
        if ($errorMessage) {
            $error['value'] = $errorMessage;
        }

        // Support explicit error handling with status = error, or generic message handling
        // with a message of type = error
        $result = [
            'status' => 'error',
            'errors' => [$error]
        ];
        $response = HTTPResponse::create(json_encode($result), $errorCode)
            ->addHeader('Content-Type', 'application/json');

        // Call a handler method such as onBeforeHTTPError404
        $this->extend("onBeforeJSONError{$errorCode}", $request, $response);

        // Call a handler method such as onBeforeHTTPError, passing 404 as the first arg
        $this->extend('onBeforeJSONError', $errorCode, $request, $response);

        // Throw a new exception
        throw new HTTPResponse_Exception($response);
    }
933659
private function createErrorResponse($code, $message = null, array $data = [])
    {
        if (!$message) {
            $messages = $this->handler->getErrors()->getErrors();
            $message = isset($messages[$code]) ? $messages[$code] : 'Error';
        }

        $json = [
            'jsonrpc' => self::JSON_RPC_VERSION,
            'error' => [
                'code' => $code,
                'message' => $message
            ],
            'id' => $this->requestId
        ];

        if ($data) {
            $json['error']['data'] = $data;
        }

        return new JsonResponse($json, 200);
    }
91673
private function parseError($errno, $error)
    {
        $this->error = '';

        if ($errno > 0) {
            // More info: http://php.net/manual/en/function.curl-errno.php
            if ($errno == CURLE_COULDNT_RESOLVE_HOST) {
                $host = parse_url($this->url);
                $host = $host['host'];

                $this->error = 'cURL error '.$errno.' : Could not resolve hostname '.$host.'...';
                $this->cwsDebug->error($this->error);

                return;
            } elseif ($errno == CURLE_HTTP_NOT_FOUND) {
                $this->error = 'cURL error '.$errno.' : HTTP error '.$this->status.'...';
                if ($this->status == 406) {
                    $this->error .= ' URL does not allow access to its content...';
                }
                $this->cwsDebug->error($this->error);

                return;
            } elseif ($errno == CURLE_COULDNT_CONNECT) {
                $this->error = 'cURL error '.$errno.' : Connection failed to the URL...';
                $this->cwsDebug->error($this->error);

                return;
            } elseif ($errno == CURLE_OPERATION_TIMEOUTED) {
                $this->error = 'cURL error '.$errno.' : Access to the URL exceeded time...';
                $this->cwsDebug->error($this->error);

                return;
            } else {
                $this->error = 'cURL error '.$errno;
                $this->cwsDebug->error($this->error);

                return;
            }
        } elseif (!empty($error)) {
            $this->error = 'cURL error : '.$error;
            $this->cwsDebug->error($this->error);

            return;
        } elseif ($this->status == 400) {
            $this->error = 'HTTP error '.$this->status.' Bad request : The request contains bad syntax or can not be transmitted.';
            $this->cwsDebug->error($this->error);

            return;
        } elseif ($this->status == 401) {
            $this->error = 'HTTP error '.$this->status.' Not allowed : The request requires authentication. Authentication failed or have not yet been accomplished.';
            $this->cwsDebug->error($this->error);

            return;
        } elseif ($this->status == 403) {
            $this->error = 'HTTP error '.$this->status.' Access denied : The server refuses to grant the resource.';
            $this->cwsDebug->error($this->error);

            return;
        } elseif ($this->status == 404) {
            $this->error = 'HTTP error '.$this->status.' Document Not Found : The server can not find the requested page in the URL.';
            $this->cwsDebug->error($this->error);

            return;
        } elseif ($this->status == 500) {
            $this->error = 'HTTP error '.$this->status.' Internal Error : The server encountered an unexpected condition which prevented him from continuing your query.';
            $this->cwsDebug->error($this->error);

            return;
        }
    }
77992
public function handleError($errno, $errstr, $errfile, $errline, $errcontext) {
        throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
    }
1069115
public function renderError($httpRequest, $errno, $errstr, $errfile, $errline)
    {
        if (!isset(self::$error_types[$errno])) {
            $errorTypeTitle = "UNKNOWN TYPE, ERRNO $errno";
        } else {
            $errorTypeTitle = self::$error_types[$errno]['title'];
        }
        $output = CLI::text("ERROR [" . $errorTypeTitle . "]: $errstr\nIN $httpRequest\n", "red", null, true);
        $output .= CLI::text("Line $errline in $errfile\n\n", "red");

        return $output;
    }
1144963
public function setErrorHandle($err, $message, $file, $line) {
        $oJsonRpc = JsonRpc::getInstance();
        $content = explode("\n", file_get_contents($file));
        header('Content-Type: application/json');
        $id = $oJsonRpc->extractId();
        $error = array(
           "code" => 100,
           "message" => "Server error",
           "error" => array(
              "name" => "PHPErorr",
              "code" => $err,
              "message" => $message,
              "file" => $file,
              "at" => $line,
              "line" => $content[$line-1]));
        ob_end_clean();
        echo $oJsonRpc->response(null, $id, $error);
        exit();
    }