Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

[Github] Enhancing error trapping #307

Open
eddieajau opened this issue Dec 5, 2013 · 1 comment
Open

[Github] Enhancing error trapping #307

eddieajau opened this issue Dec 5, 2013 · 1 comment
Labels

Comments

@eddieajau
Copy link
Contributor

Sometimes there isn't enough information about why a request fails.

https://github.com/joomla/joomla-framework/blob/staging/src/Joomla/Github/AbstractGithubObject.php#L127

Would it be appropriate to all a logger to Github, or add a callable to log debugging information for an exception. The callable could be set in the Github options so that we don't have to couple it to LoggerAwareInterface, but I'm also ok with that coupling. In the case above, we could dump the response object to the logger and try and decipher what went wrong.

@florianv
Copy link
Contributor

florianv commented Dec 5, 2013

I think it would be better to not couple it with the logger.
It could be done by creating an exception class like this.

class UnsuccessfulResponseException extends \Exception
{
    protected $response;

    public function setResponse(Response $response)
    { 
         $this->response = $response;
    }

    public function getResponse()
    { 
         return $this->response;
    }
}

and throw this exception instead, so later it's possible to do this

try
{
   $github->do...
}

catch (UnsuccessfulResponseException $e)
{
    // Do anything with the response
    $response = $e->getResponse();
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants