3 ms·
Absolutely. In fact, you're almost perfectly describing the JsonAPI standard for returning errors: https://jsonapi.org/format/#errors https://jsonapi.org/format
by DanHulton 3y ago
Absolutely. In fact, you're almost perfectly describing the JsonAPI standard for returning errors: https://jsonapi.org/format/#errors https://jsonapi.org/format/#errors
One improvement I'd steal from theirs and drop in yours - constant (or enum) string codes. It's a lot more scannable when debugging/reviewing/maintaining than having to look up integer codes in a table.
- omegabravo 3y agoJust pointing out that codes make it easier to provide translations and ability to switch between error types with more confidence than string matching. Error codes should be accompanied by helpful messages so you don't have to look up the table.