aboutsummaryrefslogtreecommitdiff
path: root/lib/trails/Exception.php
diff options
context:
space:
mode:
authorPhilipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de>2024-09-24 10:53:31 +0200
committerPhilipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de>2024-09-24 10:53:31 +0200
commit4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch)
tree5c07151ae61276d334e88f6309c30d439a85c12e /lib/trails/Exception.php
parentda0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff)
parent97a188592c679890a25c37ab78463add76a52ff7 (diff)
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'lib/trails/Exception.php')
-rw-r--r--lib/trails/Exception.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/trails/Exception.php b/lib/trails/Exception.php
new file mode 100644
index 0000000..fd92b35
--- /dev/null
+++ b/lib/trails/Exception.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace Trails;
+
+/**
+ * @author mlunzena
+ * @copyright (c) Authors
+ * @version $Id: trails.php 7001 2008-04-04 11:20:27Z mlunzena $
+ */
+class Exception extends \Exception
+{
+ protected array $headers;
+
+ /**
+ * @param int $status the status code to be set in the response
+ * @param string|null $reason a human readable presentation of the status code
+ * @param array $headers a hash of additional headers to be set in the response
+ */
+ public function __construct(int $status = 500, string $reason = null, array $headers = [])
+ {
+ parent::__construct(
+ $reason ?? Response::get_reason($status),
+ $status
+ );
+
+ $this->setHeaders($headers);
+ }
+
+ public function setHeaders(array $headers): void
+ {
+ $this->headers = $headers;
+ }
+
+ public function getHeaders(): array
+ {
+ return $this->headers;
+ }
+
+ public function __toString(): string
+ {
+ return "{$this->code} {$this->message}";
+ }
+}