Drahak\Restful\Application\UI\ResourcePresenter::createErrorResource PHP Method

createErrorResource() protected method

Create error response from exception
protected createErrorResource ( Exception | Throwable $e ) : Drahak\Restful\IResource
$e Exception | Throwable
return Drahak\Restful\IResource
    protected function createErrorResource($e)
    {
        if ($e instanceof \Exception || $e instanceof \Throwable) {
            $resource = $this->resourceFactory->create(array('code' => $e->getCode(), 'status' => 'error', 'message' => $e->getMessage()));
        } else {
            $resource = $this->resourceFactory->create(array('code' => 500, 'status' => 'error', 'message' => (string) $e));
        }
        if (isset($e->errors) && $e->errors) {
            $resource->errors = $e->errors;
        }
        return $resource;
    }