mirror of
https://github.com/morgan9e/chatgpt-web
synced 2026-04-13 16:04:05 +09:00
Add try/catch around fetch(), style system messages correctly
This commit is contained in:
@@ -62,7 +62,9 @@
|
||||
// Show updating bar
|
||||
updating = true;
|
||||
|
||||
const response: Response = await (
|
||||
let response: Response;
|
||||
try {
|
||||
response = await (
|
||||
await fetch("https://api.openai.com/v1/chat/completions", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
@@ -85,6 +87,9 @@
|
||||
}),
|
||||
})
|
||||
).json();
|
||||
} catch (e) {
|
||||
response = { error: { message: e.message } };
|
||||
}
|
||||
|
||||
// Hide updating bar
|
||||
updating = false;
|
||||
@@ -214,6 +219,7 @@
|
||||
</article>
|
||||
{:else if message.role === "system"}
|
||||
<article class="message is-danger">
|
||||
<div class="message-body">
|
||||
<SvelteMarkdown
|
||||
source={message.content}
|
||||
options={markedownOptions}
|
||||
@@ -221,6 +227,7 @@
|
||||
/*code: Code*/
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</article>
|
||||
{:else}
|
||||
<article class="message is-success">
|
||||
|
||||
Reference in New Issue
Block a user