Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow proper prototype inheritance and subclassing #105

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
remove conditional proto set
  • Loading branch information
jonchurch committed Mar 10, 2024
commit 76977e9054e8ed3f3a56e902fa848ca3c20ec450
10 changes: 0 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,6 @@ function createClientErrorConstructor (HttpError, name, code) {
// capture a stack trace to the construction point
Error.captureStackTrace(err, ClientError)

// adjust the [[Prototype]] if new.target is not this class
if (new.target && new.target !== ClientError) {
setPrototypeOf(err, new.target.prototype)
}

// redefine the error message
Object.defineProperty(err, 'message', {
enumerable: true,
Expand Down Expand Up @@ -208,11 +203,6 @@ function createServerErrorConstructor (HttpError, name, code) {
// capture a stack trace to the construction point
Error.captureStackTrace(err, ServerError)

// adjust the [[Prototype]] if new.target is not this class
if (new.target && new.target !== ServerError) {
setPrototypeOf(err, new.target.prototype)
}

// redefine the error message
Object.defineProperty(err, 'message', {
enumerable: true,
Expand Down
Loading