Skip to content

Commit

Permalink
On error, show timestamp and delete cache files
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorgalvao committed Mar 6, 2024
1 parent d7a4c4f commit 78520ad
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Workflow/chatgpt
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,16 @@ function readStream(streamFile, chatFile, pidStreamFile) {
try {
const errorMessage = JSON.parse(streamString)["error"]["message"]

if (errorMessage) return JSON.stringify({
response: `[${errorMessage}]`, // Surround in square brackets to look like other messages
behaviour: { response: "replacelast" }
})
if (errorMessage) {
// Delete stream files
deleteFile(streamFile)
deleteFile(pidStreamFile)

return JSON.stringify({
response: `[${errorMessage}] \n(${(new Date).toUTCString()})`, // Surround in square brackets to look like other messages
behaviour: { response: "replacelast" }
})
}

throw "Could not determine error message" // Fallback to the catch
} catch {
Expand Down

0 comments on commit 78520ad

Please sign in to comment.