Skip to content
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

Why catch only one type of exception ? #6

Open
qpautrat opened this issue Jan 3, 2017 · 4 comments
Open

Why catch only one type of exception ? #6

qpautrat opened this issue Jan 3, 2017 · 4 comments

Comments

@qpautrat
Copy link

qpautrat commented Jan 3, 2017

@AlexDpy Can you tell me why you decided to catch only this type of exception ?

Thank you mate !

@AlexDpy
Copy link
Contributor

AlexDpy commented Jan 4, 2017

As we can see here all those exceptions extend the \UnexpectedValueException so there are all catched

@qpautrat
Copy link
Author

qpautrat commented Jan 4, 2017

As far as i know InvalidArgumentException does not extend from UnexpectedValueException.
Moreover you should let client decide if it wants to know what really happened.

@AlexDpy
Copy link
Contributor

AlexDpy commented Jan 4, 2017

The InvalidArgumentException here is thrown when there is an error in the code.

The UnexpectedValueException is thrown when there's an error due to an external source (i.e. an expired jwt).

More infos about firebase-jwt exception in this PR

The JWTDecodeUnexpectedValueException is just here to wrap the UnexpectedValueException, and only this kind of exception. It helps to easily catch an 'external error'. Maybe it's useless and maybe we should let the raw UnexpectedValueException being thrown.

Maybe you can expose your use case so we can better understand your need ?

@qpautrat
Copy link
Author

qpautrat commented Jan 4, 2017

Fortunately I don't need, in my use case, to know what really happened. But, perhaps, later I'll.
Client should be able to know if token has expired or if signature is invalid IMO.

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

No branches or pull requests

2 participants