Added static method fromException() to \KimchiAPI\Objects > Response
This commit is contained in:
parent
a187f280f1
commit
dcb1610b81
|
@ -4,6 +4,9 @@
|
|||
|
||||
namespace KimchiAPI\Objects;
|
||||
|
||||
use Exception;
|
||||
use KimchiRPC\Abstracts\Types\ProtocolType;
|
||||
|
||||
class Response
|
||||
{
|
||||
/**
|
||||
|
@ -108,4 +111,20 @@
|
|||
|
||||
return $response_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a response from an exception
|
||||
* @param Exception $exception
|
||||
* @return Response
|
||||
*/
|
||||
public static function fromException(Exception $exception): Response
|
||||
{
|
||||
$response_object = new Response();
|
||||
|
||||
$response_object->Success = false;
|
||||
$response_object->ErrorCode = $exception->getCode();
|
||||
$response_object->ErrorMessage = $exception->getMessage();
|
||||
|
||||
return $response_object;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue