Open tobi-or-not-tobi opened 4 years ago
Currently we're generating the error payload in a generic without proper error types. The errors are generally inconsistent in the backend, which is why the code in Spartacus isn't optimised.
Since this error handling in the effects isn't exposed, other libs or customers would ideally reuse our approach.
IMO it could have some structure like
{ key/code/type: 'uniqueErrorIdentifier', context: 'idOfRequestedItem', message: 'description'}
I don't remember exactly, do we have some cases where context was about more than 1 item (otherwise context can be an object with properties pointing to them)
If backend returns only property message
which is not translated, it's mostly useless (still nice to have it for developer perspective - it's more clean than code/type to describe problem, helpful for prepare e.g. translations) and we must parse it by RegExp or use request data.
An example of this type of regexp mentioned by @Pucek9 can be found here: https://github.com/SAP/spartacus/blob/65310b29dfb3d4d984b4585a57a47bf2dc5f996c/feature-libs/organization/administration/core/http-interceptors/conflict/conflict.handler.ts#L17-L20
There are a number of issues with the current effect implementation.
What we should do:
This occurs through all effects, so we'd start with an exemplary effect to demonstrate the shape of the new effects. Therefor we should balans an example that is not too complex. Products could be a good one to start with. Carts are more urgent, but also very complex.