# 错误码

错误码列表，由 `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 |
| ---------- | ---- | --------- | ----------- |
| ErrGetAuthingTokenInfo | 110001 | 200 | Cannot get authing token from context |
| ErrUserNotFound | 110002 | 404 | User not found |
| ErrNoAuthingAppIdSecret | 110003 | 200 | Cannot get valid authing appid and appsecret |
| ErrNoLarkAppIdSecret | 110201 | 200 | Cannot get valid lark app appid and appsecret |
| ErrLarkApiBizErrorCode | 110202 | 200 | Cannot get valid lark app appid and appsecret |
| ErrLarkRequestFail | 110203 | 200 | Lark request failed |
| ErrNoBQSAFile | 110301 | 500 | Cannot get bigquery service_account file |
| ErrBGServiceFailed | 110302 | 500 | Cannot new bigquery service |
| ErrResourceNotFound | 110401 | 404 | Cannot find cloud resource |
| ErrApprovalNotFound | 110501 | 404 | Approval not found |
| ErrNotCloudOwner | 110502 | 403 | You must be the owner to submit this approval |
| ErrNotApprovalOwner | 110503 | 403 | You must be the owner of the approval |
| ErrApprovalType | 110504 | 400 | Approval type invalid |
| ErrOverBudget | 110601 | 200 | Over budget |
| ErrBudgetLowerThanCost | 110602 | 200 | Budget is lower than actual cost |
| ErrBudgetNotFound | 110603 | 200 | Budget not found |
| 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 |
| 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 |

