mirror of
https://github.com/baptisteArno/typebot.io.git
synced 2026-06-19 21:04:33 +08:00
🔊 (difyAi) Improve error handling in createChatMessage action
Related to #1892
This commit is contained in:
parent
6088a56d31
commit
a37cdb30fe
@ -1,4 +1,5 @@
|
||||
import { createAction, option } from "@typebot.io/forge";
|
||||
import { stringifyError } from "@typebot.io/lib/stringifyError";
|
||||
import { isDefined, isEmpty, isNotEmpty } from "@typebot.io/lib/utils";
|
||||
import { formatStreamPart } from "ai";
|
||||
import ky, { HTTPError } from "ky";
|
||||
@ -108,7 +109,13 @@ export const createChatMessage = createAction({
|
||||
);
|
||||
const reader = response.body?.getReader();
|
||||
|
||||
if (!reader) return {};
|
||||
if (!reader)
|
||||
return {
|
||||
httpError: {
|
||||
status: 500,
|
||||
message: "Could not get reader from Dify response",
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
stream: new ReadableStream({
|
||||
@ -172,7 +179,12 @@ export const createChatMessage = createAction({
|
||||
};
|
||||
}
|
||||
console.error(err);
|
||||
return {};
|
||||
return {
|
||||
httpError: {
|
||||
status: 500,
|
||||
message: stringifyError(err),
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
},
|
||||
@ -297,6 +309,11 @@ export const createChatMessage = createAction({
|
||||
});
|
||||
}
|
||||
console.error(err);
|
||||
return logs.add({
|
||||
status: "error",
|
||||
description: "An unknown error occurred",
|
||||
details: stringifyError(err),
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user