fix: throw hook error
This commit is contained in:
@@ -739,6 +739,13 @@ export const genTransReq = async ({ reqHook, ...args }) => {
|
|||||||
// 执行 request hook
|
// 执行 request hook
|
||||||
if (reqHook?.trim() && !events) {
|
if (reqHook?.trim() && !events) {
|
||||||
try {
|
try {
|
||||||
|
const req = {
|
||||||
|
url,
|
||||||
|
body,
|
||||||
|
headers,
|
||||||
|
userMsg,
|
||||||
|
method,
|
||||||
|
};
|
||||||
interpreter.run(`exports.reqHook = ${reqHook}`);
|
interpreter.run(`exports.reqHook = ${reqHook}`);
|
||||||
const hookResult = await interpreter.exports.reqHook(
|
const hookResult = await interpreter.exports.reqHook(
|
||||||
{
|
{
|
||||||
@@ -747,20 +754,16 @@ export const genTransReq = async ({ reqHook, ...args }) => {
|
|||||||
defaultSubtitlePrompt,
|
defaultSubtitlePrompt,
|
||||||
defaultNobatchPrompt,
|
defaultNobatchPrompt,
|
||||||
defaultNobatchUserPrompt,
|
defaultNobatchUserPrompt,
|
||||||
|
req,
|
||||||
},
|
},
|
||||||
{
|
req
|
||||||
url,
|
|
||||||
body,
|
|
||||||
headers,
|
|
||||||
userMsg,
|
|
||||||
method,
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
if (hookResult && hookResult.url) {
|
if (hookResult && hookResult.url) {
|
||||||
return genInit(hookResult);
|
return genInit(hookResult);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
kissLog("run req hook", err);
|
kissLog("run req hook", err);
|
||||||
|
throw new Error(`Request hook error: ${err.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -817,6 +820,7 @@ export const parseTransRes = async (
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
kissLog("run res hook", err);
|
kissLog("run res hook", err);
|
||||||
|
throw new Error(`Response hook error: ${err.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user