Search In This Blog

2022-12-23

Catch System.LimitException in LWC

System.LimitException cannot catch by [try...catch...] in Apex.

When call Apex method in lwc and LimitException occurred in Apex source, [try...catch...] also not working in js.

But LimitException can be catched by [Promise.catch]

Sample
Promise.all([
    promise1,
    promise2,
    promise3
]).then((values) => {
    console.log(values);
}).catch((error) => {
    // LimitException can be catched here
    console.error(error);
}).finally(() => {
    console.log('Experiment completed');
});