Diagnosing Wire Errors and Deployment Failures
By the end of this lesson, you'll be able to:
- Read the error property on a wired result to diagnose a failed call
- Recognize common deployment failure causes
- Distinguish a genuine AuraHandledException message from a generically stripped one
Prerequisites: "Salesforce Debug Logs and Apex Debugging"
Reading Wire Errors
@wire(getAccounts, { searchTerm: '$searchTerm' })
wiredAccounts(result) {
this.wiredResult = result;
if (result.error) {
console.error('Wire failed:', result.error.body?.message);
}
}
A failed wire doesn't throw — it populates the wired result's error property instead (Module 7). error.body?.message often contains the real AuraHandledException text (Module 7) if that's what the underlying Apex threw — but for a genuinely unexpected error, remember Module 7's exception-stripping behavior: the message may be generic rather than descriptive, by deliberate platform design, not a bug in the component.
Common Deployment Failures
- Insufficient Apex test coverage (Module 14) — the platform's deployment coverage requirement isn't met.
- A referenced field or object the target org doesn't have — a component or Apex class referencing something that exists in the source org but not (yet) in the deployment target.
- A syntax error caught only at deploy-time validation — code that compiles fine standalone but fails the platform's own validation step during deployment.
A Worked Example
A component shows no data, and the console logs a wire error. Working through it:
- Is
error.body.messagean actual, specificAuraHandledExceptionmessage (Module 7), or a generic one? A specific message usually points directly at the cause. - Is the Apex method actually
cacheable=true(Module 7)? A non-cacheable method used with@wirefails outright. - Is a required parameter (like
recordId) actually populated, or is itundefinedbecause a reactive$-prefixed property (Module 6) was misspelled or never set?
Working through these in a fixed order, rather than guessing randomly, converges on the real cause faster.
Exercise
A wired Apex call shows an error with a generic, non-specific message rather than the custom text the Apex method's AuraHandledException was thrown with. Explain, as a comment, the likely reason.
Show hint
Recall Module 7's explanation of exception-stripping.
Exercise
Challenge: a wire never fires at all, and no error appears either. What is a likely cause worth checking first?
Show hint
Recall Module 6's reactive parameter gotcha.
Diagnosing Wire Errors and Deployment Failures Quiz
My Notes
Log in to keep private notes on this lesson.
Questions about this lesson
No questions yet — be the first to ask.
Log in to ask a question about this lesson.
Summary
A wired result carries its own error property to inspect directly, and most deployment failures trace back to a small, recognizable set of causes once you know what to look for.