]> BookStack Code Mirror - bookstack/blobdiff - app/Exceptions/PrettyException.php
Opensearch: Fixed XML declaration when php short tags enabled
[bookstack] / app / Exceptions / PrettyException.php
index 33c1471f2849b69fd0ee667ca81d2e372700af02..606085231f77411e467b2395437373d7e5bf04d6 100644 (file)
@@ -4,27 +4,21 @@ namespace BookStack\Exceptions;
 
 use Exception;
 use Illuminate\Contracts\Support\Responsable;
+use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
 
-class PrettyException extends Exception implements Responsable
+class PrettyException extends Exception implements Responsable, HttpExceptionInterface
 {
-    /**
-     * @var ?string
-     */
-    protected $subtitle = null;
-
-    /**
-     * @var ?string
-     */
-    protected $details = null;
+    protected ?string $subtitle = null;
+    protected ?string $details = null;
 
     /**
      * Render a response for when this exception occurs.
      *
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function toResponse($request)
     {
-        $code = ($this->getCode() === 0) ? 500 : $this->getCode();
+        $code = $this->getStatusCode();
 
         return response()->view('errors.' . $code, [
             'message'  => $this->getMessage(),
@@ -46,4 +40,20 @@ class PrettyException extends Exception implements Responsable
 
         return $this;
     }
+
+    /**
+     * Get the desired HTTP status code for this exception.
+     */
+    public function getStatusCode(): int
+    {
+        return ($this->getCode() === 0) ? 500 : $this->getCode();
+    }
+
+    /**
+     * Get the desired HTTP headers for this exception.
+     */
+    public function getHeaders(): array
+    {
+        return [];
+    }
 }