From acfd6633a22ec2f30df33aa6efd95611d4800cd0 Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 28 Mar 2024 14:36:44 +0200 Subject: [PATCH] non integer errors --- src/Appwrite/Extend/Exception.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 7d56f5a384..f96057bc5b 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -296,11 +296,17 @@ class Exception extends \Exception protected array $errors = []; protected bool $publish; - public function __construct(string $type = Exception::GENERAL_UNKNOWN, string $message = null, int $code = null, \Throwable $previous = null) + public function __construct(string $type = Exception::GENERAL_UNKNOWN, string $message = null, $code = null, \Throwable $previous = null) { $this->errors = Config::getParam('errors'); $this->type = $type; $this->code = $code ?? $this->errors[$type]['code']; + + // todo: Handle better PDOExceptions or string errors + if(is_string($this->code)) { + $this->code = 500; + } + $this->message = $message ?? $this->errors[$type]['description']; $this->publish = $this->errors[$type]['publish'] ?? ($this->code >= 500);