This RFC describe how errors are rendered by CaliOpen API.
Errors must feet to multiple situations:
Errors MUST be rendered in the required content-type, generally json.
{
"errors": [
{
"description": "string",
"type": "string",
"values": ["string"],
"property": "string",
"component": "string",
"code": "string"
}
]
}
The login is not available)max-len, internal)max, value: 6)In a modifying request (POST, PUT or PATCH), the HTTP status code SHOULD be 400.
An Error MAY have a property that represents an invalid resource property.
A property MIGHT be a sub-property. In that case its path should be represented separated by dots ..
eg:
address.zip_codecontacts.azehgsqf-sdmlf45lk-alzmd.nameValues depends of the type of the error, here is a sample:
| error type | value type | description |
|---|---|---|
| type | string | unexpected type [integer, float, string, bool …] |
| min | float | min value authorized for a number |
| max | float | max value authorized |
| min-len | integer | min length authorized for a string or an array |
| … | … | … |
In case of an internal server error (HTTP status code 5xx), an Error SHOULD have a component property representing the python component (eg. caliopen.base.message).
In case of an internal server error (HTTP status code 5xx), an Error SHOULD have a code witch will MIGHT be rendered to the end-user, in order to alert the provider of the current caliopen instance.
The standard status code to use are:
| status code | case | note |
|---|---|---|
| 400 | invalid user input | |
| 401 | not authenticated | |
| 403 | unauthorized | |
| 404 | missing resource | |
| 4xx | all other situations | can be considered as not standard usage |
| 500 | internal server error | Obviously we need to fix it |