mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
PR-URL: https://github.com/nodejs/node/pull/60726 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
29 lines
650 B
JavaScript
29 lines
650 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const { AbortError } = require('internal/errors');
|
|
|
|
{
|
|
const err = new AbortError();
|
|
assert.strictEqual(err.message, 'The operation was aborted');
|
|
assert.strictEqual(err.cause, undefined);
|
|
}
|
|
|
|
{
|
|
const cause = new Error('boom');
|
|
const err = new AbortError('bang', { cause });
|
|
assert.strictEqual(err.message, 'bang');
|
|
assert.strictEqual(err.cause, cause);
|
|
}
|
|
|
|
{
|
|
assert.throws(() => new AbortError('', false), {
|
|
code: 'ERR_INVALID_ARG_TYPE'
|
|
});
|
|
assert.throws(() => new AbortError('', ''), {
|
|
code: 'ERR_INVALID_ARG_TYPE'
|
|
});
|
|
}
|