hover show errorMsg when plugin run error

This commit is contained in:
lloydzhou
2024-10-01 13:58:50 +08:00
parent 9c577ad9d5
commit 919ee51dca
4 changed files with 12 additions and 7 deletions

View File

@@ -222,10 +222,7 @@ export function stream(
),
)
.then((res) => {
let content = res.data;
try {
content = JSON.stringify(res.data);
} catch (e) {}
let content = res.data || res?.statusText;
if (res.status >= 300) {
return Promise.reject(content);
}
@@ -240,7 +237,11 @@ export function stream(
return content;
})
.catch((e) => {
options?.onAfterTool?.({ ...tool, isError: true });
options?.onAfterTool?.({
...tool,
isError: true,
errorMsg: e.toString(),
});
return e.toString();
})
.then((content) => ({