jschon icon indicating copy to clipboard operation
jschon copied to clipboard

Provide Error Code along with error messages in output format

Open jugaadi opened this issue 3 years ago • 1 comments

As a library user, it would be helpful if jschon can provide numeric error codes( and name if possible) in addition to the error messages in output format since we may have to translate the same in other languages.

  1. Current error node can point to error code instead of the message.
  2. title and description annotations can be used to add more details of the error.

Prior art:

  1. HTTP Error Codes
  2. Typescript Error Codes
  3. Postgres Error Codes

jugaadi avatar Aug 23 '22 02:08 jugaadi

Additional context: https://github.com/json-schema-org/json-schema-spec/issues/1282

jugaadi avatar Aug 29 '22 03:08 jugaadi

I'm inclined to concur with Greg Dennis's view in the linked issue - that the keyword itself (which can be inferred from keywordLocation) can effectively be taken to be the error code.

I do agree though that error messaging in jschon needs work, in terms of allowing customization and localization. I'll create a separate issue for this.

marksparkza avatar Sep 11 '22 10:09 marksparkza

PS: The suggestions by Greg Dennis will only be reflected in the next version of JSON Schema.

jugaadi avatar Sep 12 '22 02:09 jugaadi