Pass the error out to the processor
This commit is contained in:
parent
6cbec224b6
commit
dccdd48cfc
1 changed files with 11 additions and 19 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue