Add RpcException and StandardException classes
This commit is contained in:
parent
7d922f348f
commit
14d46d1a9a
2 changed files with 48 additions and 0 deletions
21
src/Socialbox/Exceptions/RpcException.php
Normal file
21
src/Socialbox/Exceptions/RpcException.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Socialbox\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
class RpcException extends Exception
|
||||
{
|
||||
/**
|
||||
* Throws when there is an RPC exception that couldn't be handled
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct(string $message="", int $code=0, ?Throwable $previous=null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
27
src/Socialbox/Exceptions/StandardException.php
Normal file
27
src/Socialbox/Exceptions/StandardException.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Socialbox\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Socialbox\Enums\StandardError;
|
||||
use Throwable;
|
||||
|
||||
class StandardException extends Exception
|
||||
{
|
||||
/**
|
||||
* Thrown as a standard error, with a message and a code
|
||||
*
|
||||
* @param string $message
|
||||
* @param StandardError $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct(string $message, StandardError $code, ?Throwable $previous=null)
|
||||
{
|
||||
parent::__construct($message, $code->value, $previous);
|
||||
}
|
||||
|
||||
public function getStandardError(): StandardError
|
||||
{
|
||||
return StandardError::from($this->code);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue