-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AbstractProvider - unexpected, undocumented exceptions #880
Labels
Comments
You can probably adjust your code to catch the different exceptions? try {
$accessToken = $provider->getAccessToken($grant, array $options = [])
} catch (IdentityProviderException $e) {
// handle IdentityProviderException exceptions here
} catch (UnexpectedValueException $e) {
// handle UnexpectedValueException exceptions here
} OR try {
$accessToken = $provider->getAccessToken($grant, array $options = [])
} catch (IdentityProviderException | UnexpectedValueException $e) {
// handle IdentityProviderException and UnexpectedValueException exceptions here
} See: https://www.php.net/manual/en/language.exceptions.php#language.exceptions.catch |
Thank you for your reply.
You’re right and it’s pretty straightforward to catch all the exceptions once you know they may be thrown.
What I’d like to see improved is the clarity of the documentation (or the documented code). I believe it’d be great if developers could write all the necessary catch blocks based solely on the documentation, without the need of debugging their code, analyzing logs etc.
… On 3. Aug 2021, at 09:13, cloudcogsio ***@***.***> wrote:
You can probably adjust your code to catch the different exceptions?
try {
$accessToken = $provider->getAccessToken($grant, array $options = [])
} catch (IdentityProviderException $e) {
// handle IdentityProviderException exceptions here
} catch (UnexpectedValueException $e) {
// handle UnexpectedValueException exceptions here
}
OR
try {
$accessToken = $provider->getAccessToken($grant, array $options = [])
} catch (IdentityProviderException | UnexpectedValueException $e) {
// handle IdentityProviderException and UnexpectedValueException exceptions here
}
See: https://www.php.net/manual/en/language.exceptions.php#language.exceptions.catch
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
Thanks for the suggestion, @lukaszmakuch. We'll keep this open until we've added appropriate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello! 👋
First of all, thank you for this project. It has saved me tons of time! 👍
I'm opening this issue to discuss the exceptions thrown by the
AbstractProvider
class.When working with a provider, like the
GenericProvider
, I'd expect to catch someIdentityProviderException
s. Its nicely documented:However, much to my surprise, some methods such as
getAccessToken
orgetResourceOwner
may throw anUnexpectedValueException
when there's something wrong with the response received from the Identity Provider. Sadly, this is not documented.To be honest, I expected to catch nothing but
IdentityProviderException
s and my code broke because there was no catch block forUnexpectedValueException
s.What are your thoughts on this matter? 🤔 Should the fact that an
UnexpectedValueException
may be thrown be documented? Or maybe we can risk some breaking changes and modify the code to throwIdentityProviderException
s instead ofUnexpectedValueException
s?Cheers!
The text was updated successfully, but these errors were encountered: