Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 97176fd

Browse files
Add try catch (#1280)
1 parent e9c6a36 commit 97176fd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

engine/commands/chat_cmd.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ struct ChunkParser {
2626
if (s.find("[DONE]") != std::string::npos) {
2727
is_done = true;
2828
} else {
29-
content = nlohmann::json::parse(s)["choices"][0]["delta"]["content"];
29+
try {
30+
content = nlohmann::json::parse(s)["choices"][0]["delta"]["content"];
31+
} catch (const nlohmann::json::parse_error& e) {
32+
CTL_WRN("JSON parse error: " << e.what());
33+
}
3034
}
3135
}
3236
}

0 commit comments

Comments
 (0)