From b08047ba485f86038f33175162943c0a9878ab1a Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Fri, 19 Sep 2025 17:03:47 +0200 Subject: add separate matrix specification package --- matrix-specification/Errors/Error.php | 41 ++++++++++++++++++++++++++ matrix-specification/Errors/RateLimitError.php | 20 +++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 matrix-specification/Errors/Error.php create mode 100644 matrix-specification/Errors/RateLimitError.php (limited to 'matrix-specification/Errors') diff --git a/matrix-specification/Errors/Error.php b/matrix-specification/Errors/Error.php new file mode 100644 index 0000000..2adc642 --- /dev/null +++ b/matrix-specification/Errors/Error.php @@ -0,0 +1,41 @@ +errorCode; + } + + public function getHttpCode(): int + { + return $this->getCode(); + } + + /** + * @return array + */ + abstract public function getAdditionalData(): array; + + public function jsonSerialize(): array + { + return [ + "errcode" => $this->getErrorCode(), + "error" => $this->getMessage(), + ...$this->getAdditionalData(), + ]; + } +} diff --git a/matrix-specification/Errors/RateLimitError.php b/matrix-specification/Errors/RateLimitError.php new file mode 100644 index 0000000..2f4193c --- /dev/null +++ b/matrix-specification/Errors/RateLimitError.php @@ -0,0 +1,20 @@ + $this->retryAfterMilliseconds, + ]; + } +} -- cgit v1.2.3