How should developers handle and parse error objects returned by wired data adapters in LWC?
Answer
Basics: A wired property resolves to { data, error }; exactly one is populated. For imperative Apex use try/catch or .catch. The error typically has status (HTTP code), statusText and body. For Apex exceptions body.message holds the text; for UI API (LDS) errors body can be an array of objects or an object with message, output.errors and output.fieldErrors.
How it works: In a wire handler, check error, convert it to a readable string, store it, and show it with lightning-card, an inline message or ShowToastEvent. For lightning-record-edit-form, onerror gives event.detail.message and event.detail.detail. For field-level problems in updateRecord use error.body.output.fieldErrors.
Advanced / deep dive: Throw AuraHandledException from Apex and call setMessage() so the client gets a clean, user-safe message; other exceptions arrive as generic text or expose stack details. Distinguish categories: network failure (status 0 or missing), permission or sharing problems (403 or INSUFFICIENT_ACCESS), validation failures (FIELD_CUSTOM_VALIDATION_EXCEPTION), and concurrency (UNABLE_TO_LOCK_ROW). Do not show raw technical messages to end users; log them (for example via a platform event or custom log object) and show friendly text. For wires, remember an error replaces data with undefined, so templates must handle both states. In Jest, simulate with .