From dccdd48cfcd7dc76dabdc73d179736680615865f Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sat, 4 May 2024 10:40:16 +0800 Subject: [PATCH] Pass the error out to the processor --- scripts/data/product.js | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/scripts/data/product.js b/scripts/data/product.js index fecc343..1e4f962 100644 --- a/scripts/data/product.js +++ b/scripts/data/product.js @@ -52,9 +52,6 @@ export default class product { // Stop when not attached (basically, not entirely initialized). 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. if (this.status[`update`]) { // Save the data to the storage. @@ -80,25 +77,20 @@ export default class product { // Add the prompt. PROMPT.push({"text": ((new texts(`AI_message_prompt`)).localized).concat(JSON.stringify(this.details))}); - - try { - // Run the analysis. - await analyzer.generate(PROMPT); + // Run the analysis. + await analyzer.generate(PROMPT); - // Raise an error if the product analysis is blocked. - if (analyzer.blocked) { - throw new Error((new texts(`error_msg_blocked`)).localized) - }; + // Raise an error if the product analysis is blocked. + if (analyzer.blocked) { + throw new Error((new texts(`error_msg_blocked`)).localized) + }; - if (analyzer.candidate) { - // Remove all markdown formatting. - this.analysis = JSON.parse(analyzer.candidate.replace(/(```json|```|`)/g, '')); - }; - } catch(err) { - await session.write([`sites`, this.URL, `error`], err, 1); - throw err; - } + if (analyzer.candidate) { + // Remove all markdown formatting. + this.analysis = JSON.parse(analyzer.candidate.replace(/(```json|```|`)/g, '')); + }; + }; return(this.analysis);