-
Notifications
You must be signed in to change notification settings - Fork 3
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 #5 from polidog/exception
エラー処理の変更
- Loading branch information
Showing
3 changed files
with
64 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
namespace Polidog\Esa\Exception; | ||
|
||
use GuzzleHttp\Exception\ClientException; | ||
|
||
class ApiErrorException extends \RuntimeException | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $apiMethodName; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $args; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getApiMethodName() | ||
{ | ||
return $this->apiMethodName; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getArgs() | ||
{ | ||
return $this->args; | ||
} | ||
|
||
/** | ||
* @param \Exception $e | ||
* @param $name | ||
* @param array $args | ||
* @return ApiErrorException | ||
*/ | ||
public static function newException(\Exception $e, $name, array $args) | ||
{ | ||
$self = new self(sprintf("Api method error: %s", $name), $e->getCode(), $e); | ||
$self->apiMethodName = $name; | ||
$self->args = $args; | ||
return $self; | ||
} | ||
|
||
} |
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