Pass the error out to the processor

This commit is contained in:
buzz-lightsnack-2007 2024-05-04 10:40:16 +08:00
parent 6cbec224b6
commit dccdd48cfc

View file

@ -52,9 +52,6 @@ export default class product {
// Stop when not attached (basically, not entirely initialized). // Stop when not attached (basically, not entirely initialized).
if (!this.#snip) {throw new ReferenceError((new texts(`error_msg_notattached`)).localized)}; if (!this.#snip) {throw new ReferenceError((new texts(`error_msg_notattached`)).localized)};
// Write the data to the session storage, indicating that it is the last edited.
(this[`analysis`]) ? await session.write([`sites`, this.URL, `analysis`], this.analysis) : false;
// There is only a need to save the data if an update is needed. // There is only a need to save the data if an update is needed.
if (this.status[`update`]) { if (this.status[`update`]) {
// Save the data to the storage. // Save the data to the storage.
@ -81,8 +78,6 @@ export default class product {
// Add the prompt. // Add the prompt.
PROMPT.push({"text": ((new texts(`AI_message_prompt`)).localized).concat(JSON.stringify(this.details))}); PROMPT.push({"text": ((new texts(`AI_message_prompt`)).localized).concat(JSON.stringify(this.details))});
try {
// Run the analysis. // Run the analysis.
await analyzer.generate(PROMPT); await analyzer.generate(PROMPT);
@ -95,10 +90,7 @@ export default class product {
// Remove all markdown formatting. // Remove all markdown formatting.
this.analysis = JSON.parse(analyzer.candidate.replace(/(```json|```|`)/g, '')); this.analysis = JSON.parse(analyzer.candidate.replace(/(```json|```|`)/g, ''));
}; };
} catch(err) {
await session.write([`sites`, this.URL, `error`], err, 1);
throw err;
}
}; };
return(this.analysis); return(this.analysis);