Open d4nielRV opened 4 years ago
Hi!
We'd love to provide an enumeration for error types. This is for our sake too. However, a number of them (most, in fact) come from the backend and we can't insure that all the other cases are (or will be) covered.
We're looking into offering some form of string typealias for error type with the most common values being predefined – effectively making integration look a lot like your code.
This might take a little bit of time, however. We'll keep the issue open and update you as it comes out!
Is your feature request related to a problem? Please describe. As part of the Flows & Errors Handling documentation: https://developers.klarna.com/documentation/in-app/overview/inapp-sdk-flows/ you provide a list of cases which should be handled by the developer such as Rejected Authorize or Invalid Client Token. In that documentation:
In the callback klarnaFailed you provide as parameter an instance of KlarnaPaymentError which contains a couple of attributes: action and message. Those properties have to be checked in order to detect the kind of error, but since they are Strings we don't have a list of the errors that could be returned by the SDK.
Describe the solution you'd like Defining an enum the kind of error would let us to keep a clear code to handle those errors. For example, following your documentation, the error.name ShowFormFalseError is being used for multiple errors depending on the action (Load, Authorize, etc.).
Current status:
Our proposal:
Actually comparing Strings is not so secure solution because in case any developer or even you as SDK provider has any typo, the error handling will fail.
Describe alternatives you've considered At least provide a list of possible values for both action and name properties.
Additional context N/A