Skip to content

Commit 11e8945

Browse files
committed
Add default error handling instead of failing silently
1 parent 35e1471 commit 11e8945

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

force-app/main/default/lwc/jsButtonLwc/jsButtonLwc.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,16 @@ export default class JsButtonLwc extends LightningElement {
9797
new RegExp(REGEX_INSERT_UPSERT, "gi"),
9898
"await this.executeDml('$1',$3,'$2');"
9999
);
100-
//eslint-disable-next-line
101-
let op = await Function("recordId", `return (async ()=>{${js}})()`).bind(
102-
this
103-
)(this.recordId);
104-
return op;
100+
101+
try {
102+
//eslint-disable-next-line
103+
let op = await Function("recordId", `return (async ()=>{${js}})()`).bind(
104+
this
105+
)(this.recordId);
106+
return op;
107+
} catch (err) {
108+
console.error("An error occurred " + err.message);
109+
alert("Unhandled error in script " + err.message);
110+
}
105111
}
106112
}

0 commit comments

Comments
 (0)