aura:systemError
エラーが発生したことを示します。
このイベントは、サーバ側のアクションの実行中にエラーが発生した場合に自動的に起動されます。aura:systemError イベントは、クライアント側のコントローラで処理されます。このイベントを処理するには、マークアップでコンポーネントに <aura:handler event="aura:systemError"> タグを 1 つだけ指定します。
次の例に、エラーをトリガするボタンと、aura:systemError イベントのハンドラを示します。
1<aura:handler event="aura:systemError" action="{!c.handleError}"/>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>次のクライアント側のコントローラは、エラーの起動をトリガし、そのエラーを処理します。
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})
aura:systemError イベントの aura:handler タグには、次の必須属性があります。
| 属性名 | 型 | 説明 |
|---|---|---|
| event | String | イベント名。aura:systemError に設定する必要があります。 |
| action | Object | イベントを処理するクライアント側のコントローラアクション。 |
aura:systemError イベントには、次の属性があります。event.getParam("attributeName") を使用して属性値を取得できます。
| 属性名 | 型 | 説明 |
|---|---|---|
| message | String | エラーメッセージ。 |
| error | String | error オブジェクト。 |