-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved exceptions and added handler.
- Loading branch information
1 parent
47b9ae2
commit 81df483
Showing
20 changed files
with
870 additions
and
167 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,3 @@ plugins: | |
enabled: true | ||
exclude_patterns: | ||
- "tests/" | ||
- "src/Exceptions/ClientException.php" # empty exception |
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,52 @@ | ||
<?php | ||
|
||
namespace Denpa\Bitcoin\Exceptions; | ||
|
||
class BadConfigurationException extends ClientException | ||
{ | ||
/** | ||
* Configuration container. | ||
* | ||
* @var array | ||
*/ | ||
protected $config; | ||
|
||
/** | ||
* Constructs new bad configuration exception. | ||
* | ||
* @param array $config | ||
* @param mixed $args,... | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(array $config, ...$args) | ||
{ | ||
$this->config = $config; | ||
|
||
parent::__construct(...$args); | ||
} | ||
|
||
/** | ||
* Gets config data. | ||
* | ||
* @return array | ||
*/ | ||
public function getConfig() | ||
{ | ||
return $this->config; | ||
} | ||
|
||
/** | ||
* Returns array of parameters. | ||
* | ||
* @return array | ||
*/ | ||
protected function getConstructorParameters() | ||
{ | ||
return [ | ||
$this->getConfig(), | ||
$this->getMessage(), | ||
$this->getCode(), | ||
]; | ||
} | ||
} |
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,52 @@ | ||
<?php | ||
|
||
namespace Denpa\Bitcoin\Exceptions; | ||
|
||
use Denpa\Bitcoin\Responses\Response; | ||
|
||
class BadRemoteCallException extends ClientException | ||
{ | ||
/** | ||
* Response object. | ||
* | ||
* @var \Denpa\Bitcoin\Responses\Response | ||
*/ | ||
protected $response; | ||
|
||
/** | ||
* Constructs new bad remote call exception. | ||
* | ||
* @param \Denpa\Bitcoin\Responses\Response $response | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(Response $response) | ||
{ | ||
$this->response = $response; | ||
|
||
$error = $response->error(); | ||
parent::__construct($error['message'], $error['code']); | ||
} | ||
|
||
/** | ||
* Gets response object. | ||
* | ||
* @return \Denpa\Bitcoin\Responses\Response | ||
*/ | ||
public function getResponse() | ||
{ | ||
return $this->response; | ||
} | ||
|
||
/** | ||
* Returns array of parameters. | ||
* | ||
* @return array | ||
*/ | ||
protected function getConstructorParameters() | ||
{ | ||
return [ | ||
$this->getResponse(), | ||
]; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.