# 错误码

错误码列表，由 `codegen -type=int -doc` 命令生成，不要对此文件做任何更改。

## 功能说明

如果返回结果中存在 `code` 字段并且不为 0，则表示调用 API 接口失败。例如：

```json
{
  "code": 100101,
  "message": "Database error"
}
```

上述返回中 `code` 表示错误码，`message` 表示该错误的具体信息。每个错误同时也对应一个 HTTP 状态码，比如上述错误码对应了 HTTP 状态码 500(Internal Server Error)。

HTTP 状态码只会有以下可能：200，400，401，403，404，500。

## 错误码列表

系统支持的错误码列表如下：

| Identifier | Code | HTTP Code | Description |
| ---------- | ---- | --------- | ----------- |
| ErrNoAPIKey | 110001 | 401 | No available apikey |
| ErrContextLengthExceeded | 110002 | 400 | Context length exceeded |
| ErrNoValidMessage | 110003 | 500 | No valid message content in openai api response |
| ErrNoLarkAppIdSecret | 110101 | 200 | Cannot get valid lark app appid and appsecret |
| ErrLarkApiBizErrorCode | 110102 | 200 | Cannot get valid lark app appid and appsecret |
| ErrLarkRequestFail | 110103 | 200 | Lark request failed |
| ErrUserNotFound | 110201 | 200 | Cannot get valid user |
| ErrSuccess | 100001 | 200 | OK |
| ErrUnknown | 100002 | 500 | Internal server error |
| ErrBind | 100003 | 400 | Error occurred while binding the request body to the struct |
| ErrValidation | 100004 | 400 | Validation failed |
| ErrTokenInvalid | 100005 | 401 | Token invalid |
| ErrNotFound | 100006 | 404 | Not found |
| ErrDatabase | 100101 | 500 | Database error |
| ErrRecordNotFound | 100102 | 200 | No records found |
| ErrEncrypt | 100201 | 401 | Error occurred while encrypting the user password |
| ErrSignatureInvalid | 100202 | 401 | Signature is invalid |
| ErrExpired | 100203 | 401 | Token expired |
| ErrInvalidAuthHeader | 100204 | 401 | Invalid authorization header |
| ErrMissingHeader | 100205 | 401 | The `Authorization` header was empty |
| ErrPasswordIncorrect | 100206 | 401 | Password was incorrect |
| ErrPermissionDenied | 100207 | 403 | Permission denied |
| ErrTokenPayload | 100208 | 401 | Fields missing in token |
| ErrNoUserLarkID | 100209 | 401 | User not found in lark |
| ErrEncodingFailed | 100301 | 500 | Encoding failed due to an error with the data |
| ErrDecodingFailed | 100302 | 500 | Decoding failed due to an error with the data |
| ErrInvalidJSON | 100303 | 500 | Data is not valid JSON |
| ErrEncodingJSON | 100304 | 500 | JSON data could not be encoded |
| ErrDecodingJSON | 100305 | 500 | JSON data could not be decoded |
| ErrInvalidYaml | 100306 | 500 | Data is not valid Yaml |
| ErrEncodingYaml | 100307 | 500 | Yaml data could not be encoded |
| ErrDecodingYaml | 100308 | 500 | Yaml data could not be decoded |
| ErrCastInterface | 100309 | 500 | Interface cannot be force cast to specific type |
| ErrHttpRequest | 100401 | 500 | Http request failed |
| ErrOpenAIHttpRequest | 100402 | 500 | OpenAI api http request failed |
| ErrQueryDBRequest | 100403 | 500 | Query db failed |
| ErrOncallBotRequest | 100404 | 500 | PingChat bot failed |
| ErrAutoXRequest | 100405 | 500 | AutoX request failed |

