From 5e00d5e5148a7aeb37d7102d91e204f29f9baf2c Mon Sep 17 00:00:00 2001 From: Volodymyr Stelmakh Date: Wed, 23 Nov 2022 13:09:17 +0100 Subject: [PATCH 1/2] add get sub message and get sub code to alibaba exception --- src/Exception/AlibabaException.php | 22 ++++++++++++++++------ tests/Exception/AlibabaExceptionTest.php | 2 ++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Exception/AlibabaException.php b/src/Exception/AlibabaException.php index 597ceb9..b72068a 100644 --- a/src/Exception/AlibabaException.php +++ b/src/Exception/AlibabaException.php @@ -4,19 +4,29 @@ namespace Kyto\Alibaba\Exception; -/** - * @internal - */ class AlibabaException extends \RuntimeException { + /** + * @internal + */ public function __construct( string $message, int $code, - string $subMessage, - string $subCode, + private string $subMessage, + private string $subCode, ?\Throwable $previous = null ) { - $message = sprintf('%s. Sub-code: "%s". Sub-message: "%s".', $message, $subCode, $subMessage); + $message = sprintf('%s. Sub-code: "%s". Sub-message: "%s".', $message, $this->subCode, $this->subMessage); parent::__construct($message, $code, $previous); } + + public function getSubMessage(): string + { + return $this->subMessage; + } + + public function getSubCode(): string + { + return $this->subCode; + } } diff --git a/tests/Exception/AlibabaExceptionTest.php b/tests/Exception/AlibabaExceptionTest.php index 0febbed..3af1f40 100644 --- a/tests/Exception/AlibabaExceptionTest.php +++ b/tests/Exception/AlibabaExceptionTest.php @@ -21,6 +21,8 @@ public function testConstruct(): void self::assertSame('Message. Sub-code: "sub.code". Sub-message: "Sub-message".', $exception->getMessage()); self::assertSame($code, $exception->getCode()); + self::assertSame($subMessage, $exception->getSubMessage()); + self::assertSame($subCode, $exception->getSubCode()); self::assertSame($previous, $exception->getPrevious()); } } From 89850356a30a3626547650e8ea358ea079775419 Mon Sep 17 00:00:00 2001 From: Volodymyr Stelmakh Date: Wed, 23 Nov 2022 16:20:57 +0100 Subject: [PATCH 2/2] add requirements to readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index e20b016..bffc6dd 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,12 @@ Alibaba SDK for PHP. This package provides a structured interface to communicate with [Alibaba Open Platform](https://developer.alibaba.com/en/doc.htm?spm=a219a.7629140.0.0.188675fe5JPvEa#?docType=1&docId=118496). +> Note, package is in development therefore public interface could be changed in future releases. + +## Requirements +Currently, the minimum required PHP version is **PHP 8.0**. +See the [composer.json](composer.json) for other requirements. + ## Installation Install the latest version with [Composer](https://getcomposer.org/): ```bash