-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! GenericErrorConstructor adaptor
- Loading branch information
Showing
9 changed files
with
220 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* eslint-disable max-classes-per-file */ | ||
import { test } from './prepare-test-env-ava.js'; | ||
|
||
// eslint-disable-next-line import/order | ||
import { passStyleOf } from '../src/passStyleOf.js'; | ||
|
||
const { getOwnPropertyDescriptor } = Object; | ||
|
||
test('style of extended errors', t => { | ||
const e1 = Error('e1'); | ||
t.throws(() => passStyleOf(e1), { | ||
message: 'Cannot pass non-frozen objects like "[Error: e1]". Use harden()', | ||
}); | ||
harden(e1); | ||
t.is(passStyleOf(e1), 'error'); | ||
const e2 = Error('e2', { cause: e1 }); | ||
harden(e2); | ||
t.is(passStyleOf(e2), 'error'); | ||
const u3 = URIError('u3', { cause: e1 }); | ||
|
||
const a4 = AggregateError([e2, u3], 'a4', { cause: e1 }); | ||
t.is(a4.message, 'a4'); | ||
t.is(a4.cause, e1); | ||
t.deepEqual(getOwnPropertyDescriptor(a4, 'cause'), { | ||
value: e1, | ||
writable: true, | ||
enumerable: false, | ||
configurable: true, | ||
}); | ||
t.deepEqual(getOwnPropertyDescriptor(a4, 'errors'), { | ||
value: [e2, u3], | ||
writable: true, | ||
enumerable: false, | ||
configurable: true, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.