Open jongotlin opened 5 years ago
Apologies about the late reply, I've been swamped (and still am).
I believe I've read an email update from Fortnox about new API limits. Perhaps a throttle would be a good idea? If the response is a standard HTML formatted 429... perhaps it's really an error on Fortnox' side of things?
Even if a throttle is implemented a 5xx-error can be returned and we cannot take for granted the response is valid json.
So, I see two options then.
Either checking the response code (assuming that Fortnox always returns the same type on the different response-codes). Or, which should be done anyway, adding a fail-safe parsing which terminates gracefully on errors. (try-catch)
And of course, parsing error messages (based on provided format) to display to the client.
Today we assume all responses are in json format but html can also be returned which causes an ErrorException (
Trying to get property 'ErrorInformation' of non-object.
)Related code https://github.com/wetcat-studios/fortie/blob/master/src/Providers/ProviderBase.php#L210-L229