This method returns a HTTP response representation of the Exception

@return \EchoIt\JsonApi\ErrorResponse
964870
public function response()
    {
        return new ErrorResponse($this->httpStatusCode, $this->code, $this->message, $this->additionalAttrs);
    }
1260129
private function handleResponse()
    {
        if (!$this->processor->error) {
            return $this->processor->response;
        }
        $error_message = null;
        $error_code    = null;
        if ($this->processor->error_code) {
            $error_message = $this->processor->error_message;
            $error_code    = $this->processor->error_code;
            if (empty($error_message)) {
                $response = json_decode($this->processor->response);
                $error_message = sprintf('(%u) %s: %s', $response->status, $response->reason, $response->message);
            }
        }
        throw new AuthnetCurlException(sprintf('Connection error: %s (%s)', $error_message, $error_code));
    }
18198
protected function handleHttpException(Exception $e)
    {
        $statusCode = $e->getStatusCode();

        // if there is no exception message just get the standard HTTP text.
        if (empty($e->getMessage())) {
            $message = Response::$statusTexts[$statusCode];
        } else {
            $message = $e->getMessage();
        }

        return $this->generateResponse('', null, $statusCode, Status::FAIL, $message);
    }
36712
public function validateAuth()
    {
        // Send a get request to the API
        $response = $this->uniRequest->get(implode([$this->authURL, 'validate/']), $this->headers);
        // Check that we get 20X back
        if (in_array($response->code, $this->validCodes)) {
            // Return the response
            return $response;
        } else {
            // If we did not get 20X throw an exception
            throw new Exception($response->body->message, $response->code);
        }
    }
233732
public function error()
    {
        $this->errors = [
            'code'    => curl_errno($this->curl),
            'message' => curl_error($this->curl)
        ];

        return $this->error();
    }
1169454
protected function getErrorResponse()
    {
        if (Request::ajax()) {
            throw new AjaxException('Element not found');
        }

        return Response::make($this->controller->run('404')->getContent(), 404);
    }
1311668
public function execute()
    {
        $this->_setOptions();

        $sResponse = $this->_execute();
        $this->_saveStatusCode();

        $iCurlErrorNumber = $this->_getErrorNumber();

        $this->_close();

        if ($iCurlErrorNumber) {
            $host = $this->getUrl();
            $parameters = http_build_query($this->getParameters(), "", "&");
            $message = $this->_getErrorMessage($iCurlErrorNumber);
            throw new Exception("cURL failed with message '$message' when calling '$host?$parameters'");
        }

        return $sResponse;
    }
61509
private function execute() {
        $curlResponse = curl_exec($this->curl);

        $error = $this->getError();
        if (!empty($error)) {
            return $this->curlException($error['error'], $error['error_no']);
        }

        return $curlResponse;
    }
514239
public function processResponse()
    {
        // Init results
        $results = [];

        foreach ($this->packets_response as $response) {
            $buffer = new Buffer($response);

            // Figure out what packet response this is for
            $response_type = $buffer->read(6);

            // Figure out which packet response this is
            if (!array_key_exists($response_type, $this->responses)) {
                throw new Exception(__METHOD__ . " response type '" . bin2hex($response_type) . "' is not valid");
            }

            // Now we need to call the proper method
            $results = array_merge(
                $results,
                call_user_func_array([$this, $this->responses[$response_type]], [$buffer])
            );

            unset($buffer);
        }

        return $results;
    }
375681
public static function httpErrors()
    {
        return function (callable $handler) {
            return function ($request, array $options) use ($handler) {
                if (empty($options['http_errors'])) {
                    return $handler($request, $options);
                }
                return $handler($request, $options)->then(
                    function (ResponseInterface $response) use ($request) {
                        $code = $response->getStatusCode();
                        if ($code < 400) {
                            return $response;
                        }
                        throw RequestException::create($request, $response);
                    }
                );
            };
        };
    }
913786
public function handler(): Response
    {
        $data = $this->validate([
            'accept' => [
                new Choice(['choices' => [true, false, 0, 1]])
            ],
            'remark' => []
        ]);
        $feedback = BulletinFeedback::find($this->getParameter('id'));
        if (!$feedback) {
            throw new HttpNotFoundException();
        }
        if ($feedback->isChecked() !== null) {
            throw new HttpForbiddenException();
        }
        $feedback->checked(!!$data['accept']);
        $feedback->remark($data['remark']);
        $feedback->save();
        $this->log('info', '[' . $feedback->getReceiver()->getUsername() . '] has feedback for bulletin [' . $feedback->getBulletin()->getId() . ']');
        return response();
    }
653743
public function handler(): Response
    {
        $bulletin = Bulletin::find($this->getParameter('id'));
        if (!$bulletin) {
            throw new HttpNotFoundException();
        }
        if (!$bulletin->isDraft()) {
            throw new HttpForbiddenException();
        }
        $data = $this->validate([
            'title' => [
                new NotBlank()
            ],
            'content' => [
                new NotBlank()
            ],
            'receivers' => []
        ]);
        $bulletin->update($data);
        $this->log('info', 'Update bulletin [' . $bulletin->getId() . ']');
        return response();
    }
215701
public function toResponseJSON()
    {
        // successful response
        $arr = array('jsonrpc' => self::JSON_RPC_VERSION);
        if ($this->result !== null) {
            $arr['result'] = $this->result;
            $arr['id'] = $this->id;
            return json_encode($arr);
        // error response
        } else {
            $arr['error'] = array('code' => $this->error_code, 'message' => $this->error_message);
            $arr['id'] = $this->id;
            return json_encode($arr);
        }
    }
750692
public function toResponse()
    {
        $response = Http::getInstance()->response();
        $response->reset();
        $response->status($this->code);
        if (is_string($this->details)) {
            $response->body($this->details);
        } elseif (is_string($this->message)) {
            $response->body($this->message);
        }

        return $response;
    }
833590
public function getResponseData(): Response
    {
        $connectionResponse = new ConnectionResponseImpl();
        $errorResponse = $this->streamSocket->read();
        if ($errorResponse !== null) {
            $this->getLogger()->error('Send error: ' . $errorResponse);
            $this->streamSocket->disconnect();
            $response = @unpack('Ccommand/Cstatus/Nidentifier', $errorResponse);
            if (!empty($response)) {
                $connectionResponse->setErrorResponse($response);
            } else {
                $connectionResponse->setErrorResponse(null);
            }
        }

        return $connectionResponse;
    }
278965
protected function errorResponse()
    {
        if(!empty($this->data['openid_return_to'])) {
            $response = array(
            'openid.mode'  => 'error',
            'openid.error' => 'Invalid request'
            );
            $this->redirect($this->response($response));
        } else {
            header('HTTP/1.1 400 Bad Request');
            $response = array(
                'ns' => $this->ns,
                'error' => 'Invalid request'
                );
            echo $this->keyValueForm($response);
        }
        die();
    }
407083
public function handler(): Response
    {
        $bulletin = Bulletin::find($this->getParameter('id'));
        if (!$bulletin) {
            throw new HttpNotFoundException();
        }
        $response = [];
        foreach ($bulletin->getFeedbacks() as $feedback) {
            $response[] = [
                'id' => $feedback->getId(),
                'updatedAt' => $feedback->getUpdatedAt() ? $feedback->getUpdatedAt()->getTimestamp() : null,
                'receiver' => [
                    'id' => $feedback->getReceiver()->getId(),
                    'username' => $feedback->getReceiver()->getUsername(),
                    'name' => $feedback->getReceiver()->getName()
                ],
                'checked' => $feedback->isChecked(),
                'remark' => $feedback->getRemark()
            ];
        }
        return response($response);
    }