paquettg / leaguewrap

League of Legend API wrapper
MIT License
68 stars 28 forks source link

Attach response to response exception #125

Closed m1so closed 7 years ago

m1so commented 7 years ago

This PR attaches Response to ResponseException for better accessibility to headers. It is an extension to PR #122, based on proposal in #119.

try {
    // ...
} catch (LeagueWrap\Response\ResponseException $e) {
    $response = $e->getResponse(); // Instance of LeagueWrap\Response
    // In some cases like resolving 429 status codes, information from headers could be useful
    // see: https://developer.riotgames.com/docs/rate-limiting 
    $headers = $response->getHeaders(); // ['Retry-After' => ..., ...]
    $response->hasHeader('Retry-After');
    $response->getHeader('that does not exist'); // null
}
coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.02%) to 95.525% when pulling f81fe841e2352b20b868ee7a7ca87ac3ea394f18 on m1so:exceptions-response into f6e21cece0a70b2af95d1a37574f9837d9f44b15 on paquettg:master.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.02%) to 95.523% when pulling 6c610c7ddd482c7782ab28f7a5160d75add62f6c on m1so:exceptions-response into f6e21cece0a70b2af95d1a37574f9837d9f44b15 on paquettg:master.