ApiModel icon indicating copy to clipboard operation
ApiModel copied to clipboard

Distinguishing between Server errors and validation errors

Open cheneveld opened this issue 9 years ago • 2 comments

This PR -> https://github.com/erkie/ApiModel/pull/29, shows how validation errors are lost. But the question is who should own knowning what a validation error means? ApiModel or the implementer?

Should ApiModel conform to standard rails json for errors?

Should ApiModel Objects contain virtual (or realmed) errors?

Should Server error json be standardized? as to populate the error message from json instead of hardcoded default errror message seen here -> https://github.com/AdeptMobile/ApiModel/blob/6e33fa9aaa4143bf9a7ee9ab0ebf9d4d0141671b/Tests/ApiFormTests.swift#L84

Food for thought.

cheneveld avatar Jan 19 '16 17:01 cheneveld

Great questions. I think ApiModel should come with some sort of default error handling, perhaps the rails format it expects today. Customizing error messages and parsing probably goes hand-in-hand with https://github.com/erkie/ApiModel/issues/14.

I'm not sure about the usefulness of persisting errors and error messages on disk. What's your envisioned use-case?

By standardized error json do you mean to make it configurable? That does sound pretty smart. I wonder if it should be handled in parsers though. The hard-coded error message that's there now does not scale very well...

erkie avatar Jan 20 '16 22:01 erkie

https://github.com/erkie/ApiModel/pull/31makes a clear distinction between the types of errors

cheneveld avatar Jan 21 '16 19:01 cheneveld