aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/javascript/reference/global_objects/aggregateerror/index.html
blob: b83db1139e08e39141714f5f8593aa4ca05cef2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
title: AggregateError
slug: Web/JavaScript/Reference/Global_Objects/AggregateError
tags:
  - AggregateError
  - 실험적
  - 인터페이스
  - 자바스크립트
  - 클래스
translation_of: Web/JavaScript/Reference/Global_Objects/AggregateError
---
<div>{{JSRef}}</div>

<p><code><strong>AggregateError</strong></code> 객체는 다수의 에러가 한 에러로 랩핑되어야 할 때의 오류를 나타냅니다. 한 작업에서 여러개의 오류가 보고될 때 발생하는데, 대표적으로 {{JSxRef("Promise.any()")}}에 전달된 모든 promise들이 거부되었을 때 발생합니다.</p>

<h2 id="Constructor">Constructor</h2>

<dl>
 <dt>{{jsxref("Global_Objects/AggregateError/AggregateError", "AggregateError()")}}</dt>
 <dd>새로운 <code>AggregateError</code> 객체를 생성합니다.</dd>
</dl>

<h2 id="Instance_properties">Instance properties</h2>

<dl>
 <dt>{{JSxRef("Error.prototype.message", "AggregateError.prototype.message")}}</dt>
 <dd>에러 메시지, 기본값 <code>""</code>.</dd>
 <dt>{{JSxRef("Error.prototype.name", "AggregateError.prototype.name")}}</dt>
 <dd>에러 이름, 기본값 <code>AggregateError</code>.</dd>
</dl>

<h2 id="Examples">Examples</h2>

<h3 id="AggregateError_다루기">AggregateError 다루기</h3>

<pre class="brush: js; notranslate">Promise.any([
  Promise.reject(new Error("some error")),
]).catch(e =&gt; {
  console.log(e instanceof AggregateError); // true
  console.log(e.message);                   // "All Promises rejected"
  console.log(e.name);                      // "AggregateError"
  console.log(e.errors);                    // [ Error: "some error" ]
});
</pre>

<h3 id="AggregateError_발생시키기">AggregateError 발생시키기</h3>

<pre class="brush: js; notranslate">try {
  throw new AggregateError([
    new Error("some error"),
  ], 'Hello');
} catch (e) {
  console.log(e instanceof AggregateError); // true
  console.log(e.message);                   // "Hello"
  console.log(e.name);                      // "AggregateError"
  console.log(e.errors);                    // [ Error: "some error" ]
}
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('Promise.any', '#sec-aggregate-error-objects', 'AggregateError')}}</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>


<p>{{Compat("javascript.builtins.AggregateError")}}</p>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{JSxRef("Error")}}</li>
</ul>