Skip to content

Commit 76b0c41

Browse files
committed
feat: log http error
1 parent 2f87a18 commit 76b0c41

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/lib/error.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export async function forwardError(c: Context, error: unknown) {
1616
consola.error("Error occurred:", error)
1717

1818
if (error instanceof HTTPError) {
19+
consola.error("HTTP error:", await error.response.json())
1920
const errorText = await error.response.text()
2021
return c.json(
2122
{

src/services/copilot/create-chat-completions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import consola from "consola"
12
import { events } from "fetch-event-stream"
23

34
import { copilotHeaders, copilotBaseUrl } from "~/lib/api-config"
@@ -21,8 +22,10 @@ export const createChatCompletions = async (
2122
body: JSON.stringify(payload),
2223
})
2324

24-
if (!response.ok)
25+
if (!response.ok) {
26+
consola.error("Failed to create chat completions", response)
2527
throw new HTTPError("Failed to create chat completions", response)
28+
}
2629

2730
if (payload.stream) {
2831
return events(response)

0 commit comments

Comments
 (0)