This callback is called whenever an invalid request is processed.

@return Jaxon\Response\Response  the Jaxon response
779521
public function onEventError(Exception $e)
    {
        if(($this->xErrorCallback))
        {
            call_user_func_array($this->xErrorCallback, array($this->xResponse, $e));
        }
        else
        {
            throw $e;
        }
        return $this->xResponse;
    }
523644
public static function error()
    {
        $response = response(Admin::content()->withError(trans('admin.deny')));

        if (!request()->pjax() && request()->ajax()) {
            abort(403, trans('admin.deny'));
        }

        Pjax::respond($response);
    }
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));
    }
1253926
public function handleRequest()
    {
        try {
            $this->response = parent::handleRequest();
        } catch (HttpException $ex) {
            $this->config->set('page_title', 'Error');

            $view = new View('exception');
            $view->exception = $ex;

            $this->response->setResponseCode($ex->getErrorCode());
            $this->response->setContent($view->render());
        } catch (\Exception $ex) {
            $this->config->set('page_title', 'Error');

            $view = new View('exception');
            $view->exception = $ex;

            $this->response->setResponseCode(500);
            $this->response->setContent($view->render());
        }

        if ($this->response->hasLayout() && $this->controller->layout) {
            $this->setLayoutVariables($this->controller->layout);

            $this->controller->layout->content  = $this->response->getContent();
            $this->response->setContent($this->controller->layout->render());
        }

        return $this->response;
    }
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();
    }
136845
public function getResponse()
    {
        if ($this->response === null and $this->isExecuted()) {
            $this->response = Response::forge($this);
        }

        return $this->response;
    }
964870
public function response()
    {
        return new ErrorResponse($this->httpStatusCode, $this->code, $this->message, $this->additionalAttrs);
    }
49238
public function handler(): Response
    {
        $role = Role::find($this->getParameter('id'));
        if (!$role) {
            throw new HttpForbiddenException();
        }
        $this->log('info', 'Delete role [' . $role->getSlug() . ']');
        $role->delete(true);
        return response();
    }
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;
    }
488575
public function getJsonResponse()
    {
        $json = json_decode($this->httpResponse);
        if (is_null($json) && json_last_error() != JSON_ERROR_NONE) {
            return null; // decode error
        } else {
            return is_object($json) ? $json : null;
        }
    }
1021888
protected function processNotAuthorized()
    {
        $loginPage = $this->currentSite->getLoginPage();
        $notAuthorized = $this->currentSite->getNotAuthorizedPage();
        $returnToUrl = urlencode($this->request->getServer('REQUEST_URI'));
        $newResponse = new Response();
        $newResponse->setStatusCode('302');

        if (!$this->userService->hasIdentity()) {
            $newResponse->getHeaders()
                ->addHeaderLine(
                    'Location: ' . $loginPage . '?redirect=' . $returnToUrl
                );
        } else {
            $newResponse->getHeaders()
                ->addHeaderLine(
                    'Location: ' . $notAuthorized
                );
        }

        return $newResponse;
    }
789454
public function validate()
    {
        foreach($this->rules() as $key => $value) {
            $this->rules[$key] =  [$this->input($key), $value];
        }

        $validate = $this->validator->validate($this->rules);

        if ($validate->fails()) {
            if($this->isAjax()) {
                return $this->response->json(['errors' => $validate->errors()->all()], 403);
            }

            return $this->redirect->backWith('errors', $validate->errors()->all());
        }
    }
974929
public function getResponse()
    {
        $this->response = new ResponseDocument();
        $this->response->addElement("responseDate", $this->toUtcDateTime(new \DateTime()));
        $requestNode = $this->response->createElement("request", $this->repository->getBaseUrl());
        $this->response->getDocument()->documentElement->appendChild($requestNode);

        try {
            $this->checkVerb();
            $verbOutput = $this->doVerb();

            // we are sure now that all request variables are correct otherwise an error would have been thrown
            foreach ($this->params as $k => $v) {
                $requestNode->setAttribute($k, $v);
            }

            // the element is only added when everything went fine, otherwise we would add error node(s) in the catch
            // block below
            $this->response->getDocument()->documentElement->appendChild($verbOutput);

            // Shift the records from the records stack and add them to the DOM tree
            // Records proper are always stored in the 'metadata' node
            foreach ($this->response->getDocument()->getElementsByTagName('metadata') as $item) {
                $record = array_shift($this->records);
                $node = $this->response->getDocument()->importNode($record->documentElement, true);
                $item->appendChild($node);
            }
        } catch (MultipleExceptions $errors) {
            //multiple errors happened add all of the to the response
            foreach ($errors as $error) {
                $this->response->addError($error);
            }
        } catch (\Exception $error) {
            //add this error to the response
            if ($error instanceof Exception) {
                $this->response->addError($error);
            } else {
                $this->response->addError(new Exception($error->getMessage()));
            }
        }

        return $this->response->getResponse();
    }
416082
protected function handlePatch() : HttpResponse
    {
        $uploadKey = $this->request->key();

        if ( ! $meta = $this->cache->get($uploadKey)) {
            return $this->response->send(null, HttpResponse::HTTP_GONE);
        }

        $status = $this->verifyPatchRequest($meta);

        if (HttpResponse::HTTP_OK !== $status) {
            return $this->response->send(null, $status);
        }

        $file     = $this->buildFile($meta);
        $checksum = $meta['checksum'];

        try {
            $fileSize = $file->getFileSize();
            $offset   = $file->setKey($uploadKey)->setChecksum($checksum)->upload($fileSize);

            // If upload is done, verify checksum.
            if ($offset === $fileSize) {
                if ( ! $this->verifyChecksum($checksum, $meta['file_path'])) {
                    return $this->response->send(null, self::HTTP_CHECKSUM_MISMATCH);
                }

                $this->event()->dispatch(
                    UploadComplete::NAME,
                    new UploadComplete($file, $this->getRequest(), $this->getResponse())
                );
            } else {
                $this->event()->dispatch(
                    UploadProgress::NAME,
                    new UploadProgress($file, $this->getRequest(), $this->getResponse())
                );
            }
        } catch (FileException $e) {
            return $this->response->send($e->getMessage(), HttpResponse::HTTP_UNPROCESSABLE_ENTITY);
        } catch (OutOfRangeException $e) {
            return $this->response->send(null, HttpResponse::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE);
        } catch (ConnectionException $e) {
            return $this->response->send(null, HttpResponse::HTTP_CONTINUE);
        }

        return $this->response->send(null, HttpResponse::HTTP_NO_CONTENT, [
            'Content-Type' => self::HEADER_CONTENT_TYPE,
            'Upload-Expires' => $this->cache->get($uploadKey)['expires_at'],
            'Upload-Offset' => $offset,
        ]);
    }
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();
    }
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;
    }
1308720
public function badRequest(): Response
    {
        $this->response->setStatus(400);
        $this->response->setBody('<html><title>400 Bad Request</title>400 Bad Request</html>');
        return $this->response;
    }