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
New error handling method #42
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job so far. Some new thoughts I had:
- When the error is thrown because of We could add a underlying IPG code like
error.underlyingErrorCode
that has the error code from IPG. So in addition ofisIPGError
being true, we add aunderlyingErrorCode
. Could call itunderlyingErrorCode
,ipgErrorCode
or justerrorCode
... yours to decide - we can change the name before the release anyways.
Update: just noticed you mentioned this in the PR description - my bad. - What do you think about making the error names more explicit?
BadConfigError
=>BadGatewayConfigError
orBadIPGConfigError
UserError
=>UserPaymentError
- Not sure about this one:
PaymentFailureError
could bePaymentFaultError
as well but let's see what you think - OR we could just categorize them by fault:
ConfigFaultError
,UserFaultError
andGatewayFaultError
- again, not really sure about this one either but let's talk about it
I've had the same thoughts about error codes being in a separate field as well. However it might lead to some confusion. For example if a developer sees both I'm kinda unsure what we should do but I think providing a |
That sounds good - Maybe we can add a jsdoc note and make these concerns clear |
All error constructors now use an object instead of multiple parameters. This has been done in order to simplify the constructor calls
lgtm! |
resolves #23
I've separated errors into 3 different exception objects such as discussed in #23 :
BadConfigError
: Denotes an error caused by wrong types or configurations provided by the developer. It could be an error from IPG (e.g. wrong API key) or it could be caught in the application itself (e.g. amount must be a number)UserError
: Denotes an error caused by the end user due to a behavior. (e.g. cancelling the transaction)GatewayFailureError
: Denotes an error either caused by a failure from gateway or an unrecognizable reason. (e.g. internal gateway error)All errors extend an abstract class called
MonopayError
which offers some properties:message
?: It's astring|undefined
property which contains the error message if there is anyisIPGError
: It's aboolean
property which shows whether the error was thrown from the IPG or the application itselfisSafeToDisplay
: it's aboolean
property showing whether the error message is ok to be shown to the end user or notFor the drivers that lack error codes, exceptions that are mostly thrown are
GatewayFailureError
's. Due to them being unrecognizable.TODO
GatewayFailure
's. Because we probably can't know if it was the IPG that caused the error or the user. It just seems unrecognizablemessage
. So the developers could easily follow along with the error in the official IPG documentation