Skip to content

Commit

Permalink
Add default error handling instead of failing silently
Browse files Browse the repository at this point in the history
  • Loading branch information
surajp committed Jul 12, 2020
1 parent 35e1471 commit 11e8945
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions force-app/main/default/lwc/jsButtonLwc/jsButtonLwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,16 @@ export default class JsButtonLwc extends LightningElement {
new RegExp(REGEX_INSERT_UPSERT, "gi"),
"await this.executeDml('$1',$3,'$2');"
);
//eslint-disable-next-line
let op = await Function("recordId", `return (async ()=>{${js}})()`).bind(
this
)(this.recordId);
return op;

try {
//eslint-disable-next-line
let op = await Function("recordId", `return (async ()=>{${js}})()`).bind(
this
)(this.recordId);
return op;
} catch (err) {
console.error("An error occurred " + err.message);
alert("Unhandled error in script " + err.message);
}
}
}

0 comments on commit 11e8945

Please sign in to comment.