mcfoton said about 4 years ago on API Structure and Error Handling :
Thanks for the episode! Enjoing it as always. So you've shown how to use built-in rails validations and errors structure to generate error messages for the API. How would you then suggest to handle more complex cases when you may have errors that are not connected 1 to 1 with a field on the model? For example, if the user builds a Cart on the mobile app by adding Items to it and many things can produce an error when the user clicks 'Checkout': invalid coupon, some of the items out of stock, some with reduced quantity... I believe a separate service class is the way to go (CartHandler of sorts) that would make all this checks, but how would you suggest to transalte all this different errors to the client app? Any thoughts from your experience would be very welcome :)