Salesforce Certified Platform Developer II — Question 199
A user receives the generic "An internal server error has occurred" while interacting with a custom Lightning Component.
What should the developer do to ensure a more meaningful message?
Answer options
- A. Add an onerror event handler to the tag.
- B. Add an error-view component to the markup.
- C. Use an AuraHandledException in a try/catch block.
- D. Use ProcessBuilder to catch the error.
Correct answer: C
Explanation
The correct answer, C, is appropriate because using an AuraHandledException in a try/catch block allows the developer to catch and handle specific exceptions, thus providing a more informative error message. Options A and B do not directly address handling the error contextually, while D is not suitable for handling exceptions in Lightning Components.