You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an error is returned from a provider, it would be great if Postie provided a way to listen for an error response so that a different course of action could be taken.
For example: we have a site where we're using Postie to calculate UPS rates. The site sadly doesn't do any real address validation and a user could end up entering a wrong address. We would then need to show an error to the user and modify a few other things if the call to fetch rates fails.
Even having access to the raw response from the provider in the instance of an error would be a great start, as the modifyRates event doesn't fire on an error response. Though any additional helpers would also be great. :)
The text was updated successfully, but these errors were encountered:
My immediate thoughts are to expose a custom flash() Twig function, for you to check if there are any Postie-related errors. The idea being:
{% if craft.app.session.getFlash('postie-error') %}
...
I might also propose another event for you to hook into in your modules in the event of an error. The tricky part is that a provider can return an error for all manner of reasons, so it'd be a good idea to filter out anything you show customer-facing.
In terms of adding this to the modifyRates, I might create a new event for errors, purely because an error can happen before rates are even fetched, and the responses from providers can vary.
I think both would have pretty good utility. Particularly being able to respond to an error event and take appropriate actions.
It would be nice to have access to what the error code is, but know that's pretty unlikely due to the varying APIs for the providers. But just being notified there was an error and getting access to the raw error response would be tops!
When an error is returned from a provider, it would be great if Postie provided a way to listen for an error response so that a different course of action could be taken.
For example: we have a site where we're using Postie to calculate UPS rates. The site sadly doesn't do any real address validation and a user could end up entering a wrong address. We would then need to show an error to the user and modify a few other things if the call to fetch rates fails.
Even having access to the raw response from the provider in the instance of an error would be a great start, as the
modifyRates
event doesn't fire on an error response. Though any additional helpers would also be great. :)The text was updated successfully, but these errors were encountered: