Skip to content

Commit

Permalink
better error handling for output functions
Browse files Browse the repository at this point in the history
  • Loading branch information
blurymind committed Aug 10, 2024
1 parent 12fdd6a commit a8e1fd5
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions src/public/plugins/plugin-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,35 @@ export var PluginEditor = function ({
});
}
if (this.mode === 'test') {
const extension = new Function("parameters", `return ${fileContents}`)();
console.log({ extensionData: extension(), fileContents })
if (typeof extension === 'function') {
try {
const data = extension();
if (!data) {
document.getElementById('plugin-output-previewer').value = `The function needs to return an object..
try{
const extension = new Function("parameters", `return ${fileContents}`)();
console.log({ extensionData: extension(), fileContents })
if (typeof extension === 'function') {
try {
const data = extension();
if (!data) {
document.getElementById('plugin-output-previewer').value = `The function needs to return an object..
${ExampleOutputFunction}
`
return;
}
document.getElementById('plugin-output-previewer').value = getPreviewHtml(data.modules || [], data.body, data.script)
} catch (e) {
document.getElementById('plugin-output-previewer').value = `${e.toString()}
SEE CONSOLE LOGS
${ExampleOutputFunction}
`
return;
`;
}
document.getElementById('plugin-output-previewer').value = getPreviewHtml(data.modules || [], data.body, data.script)
} catch (e) {
document.getElementById('plugin-output-previewer').value = `${ExampleOutputFunction}
SEE CONSOLE LOGS
`;
console.error(e)
return
}
return
document.getElementById('plugin-output-previewer').value = ExampleOutputFunction;
} catch(e) {
document.getElementById('plugin-output-previewer').value = `${e.toString()}
SEE CONSOLE LOGS
${ExampleOutputFunction}
`;
console.error(e)
}
document.getElementById('plugin-output-previewer').value = ExampleOutputFunction;
}
});
};
Expand Down

0 comments on commit a8e1fd5

Please sign in to comment.