forked from takayama-lily/oicq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexception.js
More file actions
51 lines (46 loc) · 1.08 KB
/
Copy pathexception.js
File metadata and controls
51 lines (46 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"use strict";
const indi = require("./lib/individual");
const troop = require("./lib/troop");
const chat = require("./lib/message/chat");
const exceptions = new Map([
[troop.kickMember, {
2: "权限不足"
}],
[troop.setAdmin, {
2: "权限不足",
3: "不存在的群员",
7: "权限不足"
}],
[troop.setTitle, {
1013: "权限不足"
}],
[troop.setCard, {
1: "权限不足"
}],
[indi.addFriend, {
2: "对方拒绝被添加",
3: "需要正确回答问题(暂不支持)",
101: "已经是好友"
}],
[chat.sendMsg, {
10: "发送失败,消息太长",
120: "发送失败,在该群被禁言"
}],
]);
class TimeoutError extends Error {}
/**
* @param {Function} fn
* @param {Number} code
* @returns {String}
*/
function getErrorMessage(fn, code) {
if (!exceptions.has(fn))
return "unknown";
const e = exceptions.get(fn);
if (!e[code])
return "unknown";
return e[code];
}
module.exports = {
getErrorMessage, TimeoutError
}