> For the complete documentation index, see [llms.txt](https://docs.dataswyft.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dataswyft.com/build/advanced-topics/pda-authentication/password-management/tutorials/data-api/6.-handling-errors.md).

# 6. Handling Errors

### Handling Errors

HAT JS error response:

```javascript
{
  cause: string,   // The cause of the error.
  message: string, // The message of the error.
  status: number   // When the cause is HAT_API_EXCEPTION you can handle the HTTP response code.
}
```

**Error Codes:**

| Cause                     | Message                                 | Error definitions                                |
| ------------------------- | --------------------------------------- | ------------------------------------------------ |
| HAT\_CLIENT\_VALIDATION   | HAT\_DOMAIN\_IS\_UNDEFINED              | `hatDomain` parameter is required                |
| HAT\_CLIENT\_VALIDATION   | RECORD\_IDS\_MISSING                    | `recordsIds` array parameter is empty or null    |
| HAT\_CLIENT\_VALIDATION   | APPLICATION\_NOT\_SUPPORTED             | application is not supported                     |
| HAT\_CLIENT\_VALIDATION   | NOT\_AUTHENTICATED                      | client is not authenticated                      |
| HAT\_TOKEN\_VALIDATION    | HAT\_TOKEN\_IS\_NOT\_VALID\_OR\_EXPIRED | Authentication token has expired or is not valid |
| HAT\_TOKEN\_VALIDATION    | HAT\_TOKEN\_IS\_UNDEFINED               | Authentication token is undefined                |
| HAT\_TOKEN\_VALIDATION    | HAT\_TOKEN\_FAILED\_TO\_DECODE          | Authentication token has failed to decode        |
| HAT\_API\_EXCEPTION       | HTTP\_RESPONSE\_FAILED                  | HTTP response failed                             |
| HAT\_FILE\_API\_EXCEPTION | FILE\_IS\_UNDEFINED                     | File parameter is undefined                      |
| HAT\_FILE\_API\_EXCEPTION | FAILED\_TO\_FETCH\_METADATA             | Failed to fetch HAT File metadata                |
| HAT\_FILE\_API\_EXCEPTION | FILE\_FAILED\_TO\_UPLOAD                | Failed to upload the file to AWS                 |
