-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from youcan-shop/YCP-987
YCP-987: Improving exception handling
- Loading branch information
Showing
13 changed files
with
133 additions
and
34 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
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 | ||
|
||
namespace YouCan\Pay\API\Exceptions; | ||
|
||
use Throwable; | ||
|
||
class BaseException extends \RuntimeException | ||
{ | ||
/** @var string|null */ | ||
protected $response; | ||
|
||
public function __construct( | ||
string $message, | ||
string $response = null, | ||
int $code = 0, | ||
Throwable $previous = null | ||
) { | ||
parent::__construct($message, $code, $previous); | ||
|
||
$this->response = $response; | ||
} | ||
|
||
public function getResponse() | ||
{ | ||
return $this->response; | ||
} | ||
|
||
public function hasResponse(): bool | ||
{ | ||
return $this->response !== null; | ||
} | ||
} |
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,10 @@ | ||
<?php | ||
|
||
namespace YouCan\Pay\API\Exceptions; | ||
|
||
/** | ||
* Exception when a client error is encountered (4xx codes) | ||
*/ | ||
class ClientException extends BaseException | ||
{ | ||
} |
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,9 @@ | ||
<?php | ||
|
||
namespace YouCan\Pay\API\Exceptions\Keys; | ||
|
||
use YouCan\Pay\API\Exceptions\ValidationException; | ||
|
||
class UnsetPrivateKeyException extends ValidationException | ||
{ | ||
} |
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,9 @@ | ||
<?php | ||
|
||
namespace YouCan\Pay\API\Exceptions\Keys; | ||
|
||
use YouCan\Pay\API\Exceptions\ValidationException; | ||
|
||
class UnsetPublicKeyException extends ValidationException | ||
{ | ||
} |
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,10 @@ | ||
<?php | ||
|
||
namespace YouCan\Pay\API\Exceptions; | ||
|
||
/** | ||
* Exception when a server error is encountered (5xx codes) | ||
*/ | ||
class ServerException extends BaseException | ||
{ | ||
} |
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,9 @@ | ||
<?php | ||
|
||
namespace YouCan\Pay\API\Exceptions\Token; | ||
|
||
use YouCan\Pay\API\Exceptions\BaseException; | ||
|
||
class MissingTokenException extends BaseException | ||
{ | ||
} |
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,7 @@ | ||
<?php | ||
|
||
namespace YouCan\Pay\API\Exceptions; | ||
|
||
class UnexpectedResultException extends BaseException | ||
{ | ||
} |
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,7 @@ | ||
<?php | ||
|
||
namespace YouCan\Pay\API\Exceptions; | ||
|
||
class UnsupportedResponseException extends BaseException | ||
{ | ||
} |
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