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
Steven P. SchramSteven P. Schram 

Where is documentation for Lightning action response object?

I am encountering expected errors returned in the response argument of my server-side controller action callback function. I can see the error messages in this object by using the Chrome Lightning plugin, but that's only a start. What is the recommended way to pull out these error messages to present to the user? I started with this blog post, but it's very rudimentary and partially inaccurate. For example, the following code from the above blog post is not working for me:
let errors = response.getError();
let message = 'Unknown error'; // Default error message
// Retrieve the error message sent by the server
if (errors && Array.isArray(errors) && errors.length > 0) {
    message = errors[0].message;
}
// Display the message
console.error(message);
message is undefined because the errors object is more complex than this.

Where can I go for the definitive guide to error handling in Lightning Components, particularly with respect to server side calls?
 
Raj VakatiRaj Vakati
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_throw_error.htm
https://developer.salesforce.com/blogs/2017/09/error-handling-best-practices-lightning-apex.html



 
Steven P. SchramSteven P. Schram
Thanks, @Raj. The first link doesn't help with the structure of the response object. The second was the same one I referenced in my original post, having the mistake I described.

I have since found this question (https://salesforce.stackexchange.com/questions/176979/best-practice-for-catching-and-displaying-action-errors-in-lightning-components) of Stack Exchange. It's a good example of how to handle these errors, but not source material for the data structure.