exam questions

Exam Certified Platform Developer II All Questions

View all questions & answers for the Certified Platform Developer II exam

Exam Certified Platform Developer II topic 1 question 341 discussion

Actual exam question from Salesforce's Certified Platform Developer II
Question #: 341
Topic #: 1
[All Certified Platform Developer II Questions]

Users report that a button on a custom Lightning web component is not working. However, there are no other details provided.

What should the developer use to ensure error messages are properly displayed?

  • A. Add the tag to the component.
  • B. Add a try-catch block surrounding the DML statement.
  • C. Use the Database method with allOrNone set to false.
  • D. Add JavaScript and HTML to display an error message.
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
moitam
9 months ago
Selected Answer: D
D. This is because Lightning web components can use JavaScript and HTML to handle errors from various sources, such as Lightning Data Service, Apex methods, or child components(1). The developer can use the errorCallback() lifecycle hook to catch errors in the component or its children, and use the lightning-formatted-rich-text element to display the error message in a user-friendly way. 1: https://developer.salesforce.com/blogs/2020/08/error-handling-best-practices-for-lightning-web-components B is not correct, because this option assumes that the error is caused by a DML statement in an Apex method. However, the question does not specify what the button does or what kind of error occurs. Moreover, a try-catch block in Apex would only handle the error on the server side, but not display it on the client side.
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...