ApexIntermediateexceptionserror-handling
Implement custom exception hierarchy for domain errors
Real World Scenario
Generic AuraHandledException messages confuse users and leak internal details.
Expected Answer
• Domain-specific exceptions extending Exception
• Error codes mapped to user-friendly LWC messages
• Log stack trace server-side only
• Consistent catch blocks in service layer
• Invocable returns structured errors not thrown to Flow
• i18n-ready message keys for Experience Cloud
Follow-Up Questions & Answers
Click to expand — each follow-up includes a direct, interview-ready answer
Main difference: use case and scale. Domain-specific exceptions extending Exception. Error codes mapped to user-friendly LWC messages. Pick based on your integration pattern and team capability. Typed exceptions improve supportability—error codes beat string matching in logs. Balance speed of delivery with maintainability.
Architect Perspective
Typed exceptions improve supportability—error codes beat string matching in logs.