Throwing AuraHandledException will stop email from being sent, so that I can't throw AuraHandledException to alert LWC and send a email in the same transaction.

My option will be either a) separating the call into 2 sequential calls. b) sending a custom message instead of throwing exception.

Did I miss anything or do you think there's a better approach?

1 Answer 1


Publish a Platform event using "Publish Immediate" - this will not be rolled back. Use a Flow or Apex Trigger to subscribe to the Platform Event and send the email. FWIW - I've written a lightweight Logging Framework that uses this same principle to write error logs to a custom object. Logging Framwork GitHub project

  • This is a good one, Thanks!
    – yongabyte
    Commented Jul 8, 2022 at 21:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .