We use System.AuraHandledException to create and throw a server-side controller error and return a custom error message in Aura component development.
Throwing an AuraHandledException('Your error message.') is not only for DML error even though it is used very commonly. It can be used to any issues. For example, the email entered by user does not match regular expression, a birthdate is after today's date, data captured fails a webservice validation, and etc.
Throwing an AuraHandledException('Your error message.') is not only for DML error even though it is used very commonly.
It can be used to any issues. For example, the email entered by user does not match regular expression, a birthdate is after today's date, data captured fails a webservice validation, and etc.