Skip to content

Commit

Permalink
Merge pull request #2 from kyto-gmbh/update-exception
Browse files Browse the repository at this point in the history
Update Alibaba exception
  • Loading branch information
vstelmakh authored Nov 23, 2022
2 parents 19408f0 + 8985035 commit aad3929
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 16 additions & 6 deletions src/Exception/AlibabaException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 2 additions & 0 deletions tests/Exception/AlibabaExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit aad3929

Please sign in to comment.