better error catching

This commit is contained in:
2023-08-25 07:58:48 +02:00
parent 4a03a72645
commit 2cd1d7b683

View File

@ -18,7 +18,9 @@ const tryCatchWrapper = (
return new Promise((resolve, _) => { return new Promise((resolve, _) => {
try { try {
Function( Function(
`"use strict";try{${codeReplace(code)}} catch (e) {console.log(e); _reportError(e);};` `"use strict";try{${codeReplace(
code
)}} catch (e) {console.log(e); _reportError(e);};`
).call(application.api); ).call(application.api);
resolve(true); resolve(true);
} catch (error) { } catch (error) {
@ -64,7 +66,7 @@ export const tryEvaluate = async (
const newFunction = new Function( const newFunction = new Function(
`"use strict";try{${codeReplace( `"use strict";try{${codeReplace(
wrappedCode wrappedCode
)}} catch (e) {console.log(e)};` )}} catch (e) {console.log(e); _reportError(e);};`
); );
addFunctionToCache(candidateCode, newFunction); addFunctionToCache(candidateCode, newFunction);
} else { } else {