-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12fcfdb
commit a80b62c
Showing
8 changed files
with
85 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Kyto\Alibaba\Exception; | ||
|
||
class AlibabaApiError extends AlibabaException | ||
{ | ||
/** | ||
* @internal | ||
*/ | ||
public function __construct( | ||
string $message, | ||
int $code, | ||
private string $subMessage, | ||
private string $subCode, | ||
?\Throwable $previous = null | ||
) { | ||
$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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Kyto\Alibaba\Exception; | ||
|
||
class UnexpectedApiResultException extends AlibabaException | ||
{ | ||
/** | ||
* @internal | ||
*/ | ||
public function __construct( | ||
string $message, | ||
int $code = 0, | ||
?\Throwable $previous = null | ||
) { | ||
parent::__construct($message, $code, $previous); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Kyto\Alibaba\Tests\Exception; | ||
|
||
use Kyto\Alibaba\Exception\UnexpectedApiResultException; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class UnexpectedApiResultExceptionTest extends TestCase | ||
{ | ||
public function testConstruct(): void | ||
{ | ||
$message = 'Message'; | ||
$code = 1; | ||
$previous = new \RuntimeException('Previous'); | ||
|
||
$exception = new UnexpectedApiResultException($message, $code, $previous); | ||
|
||
self::assertSame('Message', $exception->getMessage()); | ||
self::assertSame($code, $exception->getCode()); | ||
self::assertSame($previous, $exception->getPrevious()); | ||
} | ||
} |