0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-25 08:19:38 +01:00
nodejs/test/message/error_aggregateTwoErrors.js
Antoine du Hamel 104dac79cc lib: aggregate errors to avoid error swallowing
Uses `AggregateError` if there are more than one error with the message
of the outer error to preserve the current behaviour, or returns the
logical OR comparison of the two parameters.

PR-URL: https://github.com/nodejs/node/pull/37460
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2021-03-19 12:43:03 +01:00

14 lines
306 B
JavaScript

// Flags: --expose-internals
'use strict';
require('../common');
const { aggregateTwoErrors } = require('internal/errors');
const originalError = new Error('original');
const err = new Error('second error');
originalError.code = 'ERR0';
err.code = 'ERR1';
throw aggregateTwoErrors(err, originalError);