function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ChunWuChunWu 

How to catch Exception from FutureHandler

I have a trigger which invokes a 'future' method in an Apex class.

The method with 'future' annotation looks like the following:

 

@future (callout=true)
public static void updateDocument(Id claimId) {
    // do the web service callout
}

 Now if there is an exception thrown from this future method, it won't be caught by the calling trigger then no error message can be displayed to the end user. It looks like there is no error at all after 'Save'. But I still got email containing the exception and the debug log shows that the exception is thrown from the FutureHandler. How can I catch this exception in the trigger and display it on the page?

 

CLKCLK

you can't throw exception to related page through future method because it is async call.

but still u can handle exception in code & send it to user through mail.