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 run 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 to handle this event.
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<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 .
1swfobject.registerObject("clippy.codeblock-1", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<aura:component controller="namespace.myController">
18    <aura:handler event="aura:systemError" action="{!c.showSystemError}"/>
19    <aura:attribute name="response" type="Aura.Action"/>
20    <!-- Other component markup here -->
21    <ui:button aura:id="trigger" label="Trigger error" press="{!c.trigger}"/>
22</aura:component>
This client-side controller triggers the firing of an error and handles that error.
1swfobject.registerObject("clippy.codeblock-2", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17({
18    trigger: function(cmp, event) {
19        // Call an Apex controller that throws an error
20        var action = cmp.get("c.throwError");
21        action.setCallback(cmp, function(response){
22            cmp.set("v.response", response);
23        });
24        $A.enqueueAction(action);
25    },
26
27    showSystemError: function(cmp, event) {
28        // Handle system error
29        $A.log(cmp);
30        $A.log(event);
31    }
32})
The aura:systemError handler 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("message").
Attribute Name Type Description
message String The error message.
error String The error object.