Newer Version Available

This content describes an older version of this product. View Latest

aura:systemError

Indicates that an error has occurred.
This event is automatically fired when an error is encountered during the execution of a server-side action. The aura:systemError event is handled by a client-side controller. A component can have only one <aura:handler event="aura:systemError"> tag in markup to handle this event.
1<aura:handler event="aura:systemError" action="{!c.handleError}"/>
This example shows a button that triggers an error and a handler for the aura:systemError event .
1<aura:component controller="namespace.myController">
2    <aura:handler event="aura:systemError" action="{!c.showSystemError}"/>
3    <aura:attribute name="response" type="Aura.Action"/>
4    <!-- Other component markup here -->
5    <ui:button aura:id="trigger" label="Trigger error" press="{!c.trigger}"/>
6</aura:component>
This client-side controller triggers the firing of an error and handles that error.
1({
2    trigger: function(cmp, event) {
3        // Call an Apex controller that throws an error
4        var action = cmp.get("c.throwError");
5        action.setCallback(cmp, function(response){
6            cmp.set("v.response", response);
7        });
8        $A.enqueueAction(action);
9    },
10
11    showSystemError: function(cmp, event) {
12        // Handle system error
13        console.log(cmp);
14        console.log(event);
15    }
16})
The aura:handler tag for the aura:systemError event contains these required attributes.
Attribute Name Type Description
event String The name of the event, which must be set to aura:systemError.
action Object The client-side controller action that handles the event.
The aura:systemError event contains these attributes. You can retrieve the attribute values using event.getParam("attributeName").
Attribute Name Type Description
message String The error message.
error String The error object.