-
Notifications
You must be signed in to change notification settings - Fork 194
Error Codes
We return errors in two different methods. For the main application (marks, labels, tags, etc) we return an errors
array with a list of error numbers and messages. Below are a list of errors for both the main application and supplementary actions.
Number | Message | Notes |
---|---|---|
1 | Mark could not be archived. | Mark errors have reserved error numbers from 1 to 29. |
2 | No Marks Found. | - |
3 | Mark could not be updated. | - |
4 | Mark with this id could not be found for this account. | - |
5 | Mark could not be restored. | - |
6 | Could not add mark. | - |
7 | Could not delete mark. | - |
8 | This mark does't have a valid URL. | - |
9 | This mark does't have a valid title. | - |
30 | No `label_id` was found. | Label errors have reserved error numbers from 30 to 59. |
31 | No label found using this label_id for your account. | - |
32 | No labels found for your account. | - |
33 | This type of label could not be found. | - |
34 | Label already exists for this account. | - |
35 | No options found to update for this label. | - |
36 | Label could not be created. | - |
37 | You do not have access to create a system level label. | - |
38 | Label already exists for this account. | - |
39 | Label could not be updated. | - |
60 | No tags found. | Tag errors have reserved error numbers from 60 to 89. |
61 | No tag provided. | - |
62 | Tag could not be added. | - |
90 | Account with given email does not exist. | Password recovery errors have reserved error numbers from 90 to 99. |
91 | Invalid password recovery token. | - |
403 | Forbidden | System errors range from 400 to 699. The 400 to 599 range are only used when they make sense and tie directly into the HTTP/1.1 status codes to avoid confusion. If a 4xx or 5xx error code is used, the header status code will also set accordingly. |
404 | Not Found | Since some views are restricted to response types you make get a 404 error in the API or XMLHttpRequest if the route is for web view only. |
500 | Internal Error | - |
600 | Security token is invalid. | - |
601 | Validation Errors | If you get this error the message will be an array of errors. We return multiple validation errors if found. |
It's easy to set an error. Simply reference this list, if the error doesn't fit add a new one to the App Configuration File. After that you can call the formatError helper and send the correct error number. It will return an array with the key being the error number and value being the error message.
$this->data['errors'] = formatErrors(600);
// $this->data['errors'] would be an array that looks like this
array(
600 => 'Security token is invalid.'
);
Doing this will allow you to keep your error messages in one place and fix them once.
For actions like simple XMLHttpRequest requests to update a password, email address or reset a password we use a simplified error report. When you get your JSON response there will always be a success
key. It will be a boolean
set to true
or false
. If false the action failed, if true you are good-to-go. If false
there will also always be a message
key returned and the value will be the error message.
On success
equals true
if data is to be returned it will be provided in the form needed. Most times when success
is equal to true
, it will be the only only key/value returned.
{
'success': false,
'message': 'The reason your request failed.'
}
{
'success': true
}
{
'success': true,
'token': 'q234asdfq345asdfaw45fdsEDET'
}