Skip to content

Commit 007cafe

Browse files
committed
make HttpError throw on direct instantiaton
this change allows us to throw for createErrors.HttpError() and new createErrors.HttpError(), but not on class Foo extends createErrors.HttpError {}
1 parent 565e1a0 commit 007cafe

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function createError () {
111111

112112
function createHttpErrorConstructor () {
113113
function HttpError () {
114-
if (new.target === HttpError) {
114+
if (!new.target || new.target === HttpError) {
115115
throw new TypeError('cannot construct abstract class')
116116
}
117117
}

0 commit comments

Comments
 (0)