@param string $xsollaErrorCode
@param string $message
@param int    $httpStatus

@return WebhookResponse
6183
public static function fromErrorCode($xsollaErrorCode, $message = '', $httpStatus = 500)
    {
        $body = [
            'error' => [
                'code' => $xsollaErrorCode,
                'message' => $message,
            ],
        ];
        $encodedBody = XsollaClient::jsonEncode($body);

        return new static($httpStatus, $encodedBody);
    }
1121329
public function respondValidationError($message = "Validation Error", $data = null)
    {
        return $this->setStatusCode(ResponseHTTP::HTTP_UNPROCESSABLE_ENTITY)
            ->respondWithError($message, null, $data);
    }
826896
public function httpError($code, $message = null)
    {
        if ($this->request->isMedia() || !$response = ErrorPage::response_for($code)) {
            parent::httpError($code, $message);
        } else {
            throw new HTTPResponse_Exception($response);
        }
    }
865282
public function respondWithError($code = null, $message = null, array $data = []): JsonResponse
    {
        return $this->respond([
            'status' => [
                'type' => 'error',
                'message' => $this->getDefaultMessage($code, $message),
                'code' => $code,
                'http_code' => $this->getStatusCode(),
            ],
            'exception' => $data,
        ]);
    }
82044
public static function rpcCodeFromHttpStatusCode($httpStatusCode)
    {
        if (array_key_exists($httpStatusCode, self::$httpStatusCodeToRpcCodeMap)) {
            return self::$httpStatusCodeToRpcCodeMap[$httpStatusCode];
        }
        return ApiStatus::UNRECOGNIZED_CODE;
    }
1265893
public static function withErrorCodeAndParam($errorCode, $message, $parameter, $innerException = null)
	{
		$ex = XPath2Exception::withErrorCodeAndParams( $errorCode, $message, array( $parameter ), $innerException );
		// $ex->ErrorCode = $errorCode;
		return $ex;
	}
356322
final protected function error($message, $status = null, $nl = true)
    {
        $this->io->error($message, $status, $nl);
    }
689806
public static HttpResponse newResponse(RequestContext ctx, HttpStatus status, String message) {
        requireNonNull(ctx, "ctx");
        requireNonNull(status, "status");
        requireNonNull(message, "message");
        return newResponse0(ctx, status, null, message);
    }
928983
protected function jsonErrorResponse($errorMessage, $statusCode = 400, array $httpHeaders = array())
    {
        $statusTexts = \Symfony\Component\HttpFoundation\Response::$statusTexts;

        return $this->jsonResponse(array(
            'error' => (string) $errorMessage,
        ), array(
            'status' => array(
                'code'    => (int) $statusCode,
                'message' => $statusTexts[$statusCode],
            ),
        ), $httpHeaders);
    }
621612
protected function _redirect($url, $httpStatusCode = 302)
    {
        if (empty($url)) throw new ControllerRedirectEmptyUrlException('Cannot redirect to an empty url.');

        header('location:' . $url, true, $httpStatusCode);
        exit;
    }
4308
public function throwException(
        $message,
        $code,
        $connectionErrorNumber = null,
        $httpStatusCode = null,
        $previousException = null
    ) {
        throw new PhpCapException(
            $message,
            $code,
            $connectionErrorNumber,
            $httpStatusCode,
            $previousException
        );
    }
170686
public function respondUnauthorized($message = null): JsonResponse
    {
        return $this->setStatusCode(IlluminateResponse::HTTP_UNAUTHORIZED)
            ->respondWithError(ApiResponse::CODE_NOT_AUTHORIZED, $message);
    }
526353
protected MultiValueMap<String, Object> buildResponseEntityErrorModel(final HttpStatus code, final String message) {
        return CollectionUtils.asMultiValueMap("code",
            code.value(),
            "message", message);
    }
308366
public function errorResponse(string $errorCode = null, int $statusCode = null, $message = null):JsonResponse
    {
        return app(Responder::class)->error($errorCode, $statusCode, $message);
    }
572419
public function errorResponse($connection, $statusCode, $body=null,  $reason=null, array $headers=[])
    {
        $res= new Response($statusCode, $body);
        if(!$reason) {
            $res->statusReason = \yii\web\Response::$httpStatuses[$statusCode];
        }
        
        if($body === null){
            $res->body = \yii\web\Response::$httpStatuses[$statusCode];
            
            $errpage = $this->getErrorPageFile($res->statusCode);
            
            if($errpage) {
                ob_start();
                include $errpage;
                $res->body = ob_get_clean();
            }
        }
        
        foreach($headers as $name => $value){
            $res->headers->add($name, $value);
        }
        
        $res->headers->remove('Content-Length');
        $res->headers->set('Connection', 'Close');
        
        $connection->close($res);
    }
953060
protected static void error(
            final HttpServletResponse httpServletResponse, final String message, final HttpStatus code) {
        try {
            httpServletResponse.setContentType("text/plain");
            httpServletResponse.setStatus(code.value());
            setNoCache(httpServletResponse);
            try (PrintWriter out = httpServletResponse.getWriter()) {
                out.println("Error while processing request:");
                out.println(message);
            }

            LOGGER.error("Error while processing request: {}", message);
        } catch (IOException ex) {
            throw ExceptionUtils.getRuntimeException(ex);
        }
    }
178312
public function getHttpStatusMessage($httpStatusCode)
    {
        switch ($httpStatusCode) {
            case self::HTTP_STATUS_OK:
                return 'OK';
            case self::HTTP_STATUS_BAD_REQUEST:
                return 'Bad Request';
            case self::HTTP_STATUS_UNAUTHORIZED:
                return 'Unauthorized';
            case self::HTTP_STATUS_FORBIDDEN:
                return 'Forbidden';
            case self::HTTP_STATUS_NOT_FOUND:
                return 'Not Found';
            case self::HTTP_STATUS_NOT_ACCEPTABLE:
                return 'Not Acceptable';
            case self::HTTP_STATUS_INTERNAL_SERVER_ERROR:
                return 'Internal Server Error';
            case self::HTTP_STATUS_SERVICE_UNAVAILABLE:
                return 'Service Unavailable';
            default:
                throw new Exception('Http status message is not available.');
        }
    }