AggregateError

번역이 완료되지 않았습니다. Please help translate this article from English

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

Constructor

AggregateError()
새로운 AggregateError 객체를 생성합니다.

Instance properties

AggregateError.prototype.message
에러 메시지, 기본값 "".
AggregateError.prototype.name
에러 이름, 기본값 AggregateError.

Examples

AggregateError 다루기

Promise.any([
  Promise.reject(new Error("some error")),
]).catch(e => {
  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" ]
});

AggregateError 발생시키기

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" ]
}

Specifications

Specification
Promise.any
The definition of 'AggregateError' in that specification.

Browser compatibility

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
AggregateErrorChrome Full support 85Edge No support NoFirefox Full support 79IE No support NoOpera No support NoSafari Full support 14WebView Android Full support 85Chrome Android Full support 85Firefox Android Full support 79Opera Android No support NoSafari iOS Full support 14Samsung Internet Android No support Nonodejs Full support 15.0.0
AggregateError() constructorChrome Full support 85Edge No support NoFirefox Full support 79IE No support NoOpera No support NoSafari Full support 14WebView Android Full support 85Chrome Android Full support 85Firefox Android No support NoOpera Android No support NoSafari iOS Full support 14Samsung Internet Android No support Nonodejs Full support 15.0.0

Legend

Full support  
Full support
No support  
No support

See also