mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix: wrap error msg in Error()
This commit is contained in:
parent
e2d9e6c16e
commit
fdadfb7b30
@ -31,7 +31,7 @@ export class LaanaMessageActionHandler {
|
|||||||
estimatedSendMsgTimeout,
|
estimatedSendMsgTimeout,
|
||||||
);
|
);
|
||||||
if (!sentMsg) {
|
if (!sentMsg) {
|
||||||
throw '消息发送失败';
|
throw Error('消息发送失败');
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
msgId: sentMsg.msgId
|
msgId: sentMsg.msgId
|
||||||
|
@ -20,7 +20,7 @@ export class LaanaFileUtils {
|
|||||||
if (laanaFile.uri.oneofKind === 'cacheId') {
|
if (laanaFile.uri.oneofKind === 'cacheId') {
|
||||||
const cacheFilePath = path.join(this.cacheDir, laanaFile.uri.cacheId);
|
const cacheFilePath = path.join(this.cacheDir, laanaFile.uri.cacheId);
|
||||||
if (!fs.existsSync(cacheFilePath)) {
|
if (!fs.existsSync(cacheFilePath)) {
|
||||||
throw `请求的缓存不存在: ${laanaFile.uri.cacheId}`;
|
throw Error(`请求的缓存不存在: ${laanaFile.uri.cacheId}`);
|
||||||
}
|
}
|
||||||
return laanaFile.uri.cacheId;
|
return laanaFile.uri.cacheId;
|
||||||
} else if (laanaFile.uri.oneofKind === 'url') {
|
} else if (laanaFile.uri.oneofKind === 'url') {
|
||||||
@ -28,7 +28,7 @@ export class LaanaFileUtils {
|
|||||||
} else if (laanaFile.uri.oneofKind === 'raw') {
|
} else if (laanaFile.uri.oneofKind === 'raw') {
|
||||||
return this.createCacheFromBytes(laanaFile.uri.raw);
|
return this.createCacheFromBytes(laanaFile.uri.raw);
|
||||||
} else {
|
} else {
|
||||||
throw '不支持的缓存类型';
|
throw Error('不支持的缓存类型');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ export class LaanaMessageUtils {
|
|||||||
)
|
)
|
||||||
).msgList[0];
|
).msgList[0];
|
||||||
if (!replyMsg) {
|
if (!replyMsg) {
|
||||||
throw '回复的消息不存在';
|
throw Error('回复的消息不存在');
|
||||||
}
|
}
|
||||||
const { msgSeq, msgId, senderUin, senderUid } = replyMsg;
|
const { msgSeq, msgId, senderUin, senderUid } = replyMsg;
|
||||||
elements.push({
|
elements.push({
|
||||||
@ -82,7 +82,7 @@ export class LaanaMessageUtils {
|
|||||||
});
|
});
|
||||||
} else if (content.oneofKind === 'at') {
|
} else if (content.oneofKind === 'at') {
|
||||||
if (params.targetPeer?.type !== Peer_Type.GROUP) {
|
if (params.targetPeer?.type !== Peer_Type.GROUP) {
|
||||||
throw '试图在私聊会话中使用 At';
|
throw Error('试图在私聊会话中使用 At');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content.at.uin === '0') {
|
if (content.at.uin === '0') {
|
||||||
@ -105,7 +105,7 @@ export class LaanaMessageUtils {
|
|||||||
} else {
|
} else {
|
||||||
const uid = await this.core.apis.UserApi.getUidByUinV2(content.at.uin);
|
const uid = await this.core.apis.UserApi.getUidByUinV2(content.at.uin);
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
throw '查询用户 UID 失败';
|
throw Error('查询用户 UID 失败');
|
||||||
}
|
}
|
||||||
const info = await this.core.apis.UserApi.getUserDetailInfo(uid);
|
const info = await this.core.apis.UserApi.getUserDetailInfo(uid);
|
||||||
elements.push(at(
|
elements.push(at(
|
||||||
@ -121,7 +121,7 @@ export class LaanaMessageUtils {
|
|||||||
const sysFaces = faceConfig.sysface;
|
const sysFaces = faceConfig.sysface;
|
||||||
const face = sysFaces.find((systemFace) => systemFace.QSid === parsedFaceId.toString());
|
const face = sysFaces.find((systemFace) => systemFace.QSid === parsedFaceId.toString());
|
||||||
if (!face) {
|
if (!face) {
|
||||||
throw '未知的表情 ID';
|
throw Error('未知的表情 ID');
|
||||||
}
|
}
|
||||||
|
|
||||||
const faceType = parsedFaceId >= 222 ?
|
const faceType = parsedFaceId >= 222 ?
|
||||||
@ -147,7 +147,7 @@ export class LaanaMessageUtils {
|
|||||||
));
|
));
|
||||||
fileCacheIds.push(cacheId);
|
fileCacheIds.push(cacheId);
|
||||||
} else {
|
} else {
|
||||||
throw '未知的消息内容类型';
|
throw Error('未知的消息内容类型');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,13 +219,13 @@ export class LaanaMessageUtils {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
musicCard: () => { throw 'Unimplemented'; },
|
musicCard: () => { throw Error('Unimplemented'); },
|
||||||
};
|
};
|
||||||
|
|
||||||
async laanaPeerToRaw(peer: LaanaPeer): Promise<Peer> {
|
async laanaPeerToRaw(peer: LaanaPeer): Promise<Peer> {
|
||||||
const peerUid = await this.core.apis.UserApi.getUidByUinV2(peer.uin);
|
const peerUid = await this.core.apis.UserApi.getUidByUinV2(peer.uin);
|
||||||
if (!peerUid) {
|
if (!peerUid) {
|
||||||
throw '查询用户 UID 失败';
|
throw Error('查询用户 UID 失败');
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
chatType: peer.type === Peer_Type.GROUP ? ChatType.KCHATTYPEGROUP : ChatType.KCHATTYPEC2C,
|
chatType: peer.type === Peer_Type.GROUP ? ChatType.KCHATTYPEGROUP : ChatType.KCHATTYPEC2C,
|
||||||
@ -236,7 +236,7 @@ export class LaanaMessageUtils {
|
|||||||
|
|
||||||
async laanaMessageToRaw(msg: OutgoingMessage, params: SendMessagePing) {
|
async laanaMessageToRaw(msg: OutgoingMessage, params: SendMessagePing) {
|
||||||
if (!msg.content.oneofKind) {
|
if (!msg.content.oneofKind) {
|
||||||
throw '消息内容类型未知';
|
throw Error('消息内容类型未知');
|
||||||
}
|
}
|
||||||
return this.l2r[msg.content.oneofKind](
|
return this.l2r[msg.content.oneofKind](
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
|
Loading…
x
Reference in New Issue
Block a user