Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Response exception should hold the response #11

Open
nohponex opened this issue Jan 29, 2017 · 0 comments
Open

Response exception should hold the response #11

nohponex opened this issue Jan 29, 2017 · 0 comments
Assignees
Milestone

Comments

@nohponex
Copy link
Member

nohponex commented Jan 29, 2017

/**
 * @author Xenofon Spafaridis <nohponex@gmail.com>
 * @since 0.0.0
 */
class ResponseException extends \Exception
{
    /**
     * @var Response
     */
    private $response;

    /**
     * @var Errors
     */
    private $errors;

    /**
     * @param Errors $errors
     */
    public function __construct(Response $response)
    {
        $this->errors = (new Errors($response->getResponse()));
        $this->response = $response;

        parent::__construct('Response exception');
    }

    /**
     * @return Error[]
     */
    public function getErrors()
    {
        return $this->errors->getErrors();
    }

    /**
     * @return Response
     */
    public function getResponse(): Response
    {
        return $this->response;
    }
}
@nohponex nohponex added this to the 2.x milestone Jan 29, 2017
@nohponex nohponex self-assigned this Jan 29, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant