Skip to content

Commit 098ea7f

Browse files
author
Grace Chong
committed
fix(NODE-3724): fix issues with BSONTypeError and BSONError being unable to be checked with instanceof using Object.setPrototypeOf
1 parent d388f1e commit 098ea7f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/error.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
/** @public */
22
export class BSONError extends Error {
3+
constructor(m: string) {
4+
super(m);
5+
Object.setPrototypeOf(this, BSONError.prototype);
6+
}
7+
38
get name(): string {
49
return 'BSONError';
510
}
611
}
712

813
/** @public */
914
export class BSONTypeError extends TypeError {
15+
constructor(m: string) {
16+
super(m);
17+
Object.setPrototypeOf(this, BSONTypeError.prototype);
18+
}
19+
1020
get name(): string {
1121
return 'BSONTypeError';
1222
}

0 commit comments

Comments
 (0)