Newer Version Available
Throwing and Handling Errors
Unrecoverable Errors
Use throw new Error("error message here") for unrecoverable errors, such as an error that prevents your app from starting successfully. The error message is displayed.
This example shows you the basics of throwing an unrecoverable error in a JavaScript controller.
Here is the client-side controller source.
Recoverable Errors
To handle recoverable errors, use a component, such as ui:message, to tell users about the problem.
This sample shows you the basics of throwing and catching a recoverable error in a JavaScript controller.
Here is the client-side controller source.
The controller code always throws an error and catches it in this example. The message in the error is displayed to the user in a dynamically created ui:message component. The body of the ui:message is a ui:outputText component containing the error text.