generated from wechaty/puppet-mock
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from wechaty/add-error-class
feat: add new class WAError and enum WAErrorType
- Loading branch information
Showing
6 changed files
with
77 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { WAErrorType } from '../schema/error-type' | ||
|
||
export default class WAError extends Error { | ||
|
||
constructor (type: WAErrorType, message: string) { | ||
super(`${type} ${message}`) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
enum BASE_ERROR_TYPE { | ||
ERR_REQUEST_TIMEOUT = 'ERR_REQUEST_TIMEOUT', // 请求超时 | ||
ERR_START = 'ERR_START', // 启动异常 | ||
ERR_STOP = 'ERR_STOP', // 停止异常 | ||
} | ||
|
||
enum INIT_ERROR_TYPE { | ||
ERR_INIT = 'ERR_INIT', // 未初始化 | ||
ERR_NOT_LOGIN = 'ERR_NOT_LOGIN', // 未登录 | ||
ERR_CACHE_EXISTED = 'ERR_CACHE_EXISTED', // 缓存已存在 | ||
ERR_NO_CACHE = 'ERR_NO_CACHE', // 缓存无效 | ||
} | ||
|
||
enum MESSAGE_ERROR_TYPE { | ||
ERR_SEND_MSG = 'ERR_SEND_MSG', // 发送消息失败 | ||
ERR_SEND_MSG_TIMEOUT = 'ERR_SEND_MSG_TIMEOUT', // 发送消息超时 | ||
ERR_UNKNOWN_SEND_STATUS = 'ERR_UNKNOWN_SEND_STATUS', // 未知消息发送结果 | ||
} | ||
|
||
enum ROOM_ERROR_TYPE { | ||
ERR_ROOM_NOT_FOUND = 'ERR_ROOM_NOT_FOUND', // 群聊不存在 | ||
ERR_CREATE_ROOM = 'ERR_CREATE_ROOM', // 创建群聊失败 | ||
ERR_MODIFY_ROOM_NAME = 'ERR_MODIFY_ROOM_NAME', // 修改群名称失败 | ||
ERR_ADD_ROOM = 'ERR_ADD_ROOM', // 拉人进群失败 | ||
ERR_REMOVE_ROOM = 'ERR_REMOVE_ROOM', // 踢人出群失败 | ||
ERR_ACCEPT_ROOM_INVITATION = 'ERR_ACCEPT_ROOM_INVITATION', // 自动通过群邀请失败 | ||
ERR_ANNOUNCE_NO_PERMISSION = 'ERR_ANNOUNCE_NO_PERMISSION', // 无发送群公告权限 | ||
} | ||
|
||
enum CONTACT_ERROR_TYPE { | ||
ERR_CONTACT_NOT_FOUND = 'ERR_CONTACT_NOT_FOUND', // 联系人不存在 | ||
ERR_INVALID_CONTACT_ID = 'ERR_INVALID_CONTACT_ID', // 联系人ID无效 | ||
ERR_CONTACT_CARD_ID = 'ERR_CONTACT_CARD_ID', // 名片id异常 | ||
} | ||
|
||
export const WXWORK_ERROR_TYPE = { | ||
...BASE_ERROR_TYPE, // 基础错误类型 | ||
...INIT_ERROR_TYPE, // 初始化错误类型 | ||
...MESSAGE_ERROR_TYPE, // 消息相关错误类型 | ||
...ROOM_ERROR_TYPE, // 群相关错误类型 | ||
...CONTACT_ERROR_TYPE, // 联系人相关错误类型 | ||
} | ||
|
||
export type WAErrorType = BASE_ERROR_TYPE | INIT_ERROR_TYPE | MESSAGE_ERROR_TYPE | ROOM_ERROR_TYPE | CONTACT_ERROR_TYPE |