Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 1.09 KB

errors.md

File metadata and controls

39 lines (29 loc) · 1.09 KB

Errors

Skema uses err-object to standardize error objects.

There are two kinds of errors

  • data errors
  • initialization errors

Initialization Errors

Initialization errors are generated by methods other than .from(), such as shape(), type(), etc. And they have following properties:

  • code string(UPPERCASED_STRING) error codes.
  • message string The error message.
  • args Array<any> The arguments passed to message template of the error.
Error {
  message: "unknown type 'hahaha'",
  args: ['hahaha'],
  code: 'UNKNOWN_TYPE'
}

Data Errors

Data errors are generated by .from() method, and have following properties:

  • input any The input value of the current property
  • key string | number | null the key of the current property
    • string if the parent is an object
    • number if the parent is an array
    • null if there is no parent
  • path The accessing path of keys to reach the current property
  • code
  • message
  • args

Examples🔬