public function action_show() { $status = $this->error instanceof HttpException ? $this->error->getStatus() : '500 Internal Server Error'; $data = $this->error instanceof HttpException ? $this->error->getData() : []; $this->response->add_header('HTTP/1.1 ' . $status); $displayErrors = $this->pixie->getParameter('parameters.display_errors', false); $showErrors = false; if ($this->error instanceof HttpException) { $message = $this->error->getMessage(); if ($this->error->getCode() >= 400 || $this->error->getCode() < 100) { $showErrors = $displayErrors; } } else { if ($this->error instanceof SQLException) { if ($this->error->isVulnerable() && !$this->error->isBlind()) { $showErrors = true; $message = $this->error->getMessage(); } else { $message = "Error"; } } else { $message = $this->error->getMessage(); $showErrors = $displayErrors; } } $this->response->body = array_merge(['message' => $message, 'code' => $this->error->getCode(), 'trace' => $showErrors ? $this->error->getTraceAsString() : ""], $data); }
public function action_show() { $status = $this->error instanceof HttpException ? $this->error->getStatus() : '500 Internal Server Error'; $data = $this->error instanceof HttpException ? $this->error->getData() : []; $this->response->add_header('HTTP/1.1 ' . $status); $this->response->body = array_merge(['message' => $this->error->getMessage(), 'code' => $this->error->getCode()], $data); }
public function filterHeaders($headers, $contentType) { if ($contentType == self::JSON_CONTENT_TYPE) { if ($this->exception) { if ($this->exception instanceof \App\Exception\HttpException) { $headers['HTTP/1.1 ' . $this->exception->getStatus()] = ''; } else { $headers['HTTP/1.1 500 Internal Server Error'] = ''; } } $headers['Content-Type'] = 'application/json'; } return $headers; }