Skip to content

Allow HttpError extension by ES6 classes #98

Description

@nathanlepori

To allow better interoperability with ES6 classes (which are forced to call the super() constructor) it is better to add the following condition to the HttpError constructor:

if(this.constructor===HttpError){thrownewTypeError('cannot construct abstract class')}

This way the class can be extended with a concrete class like this:

classMyHttpErrorextendsHttpError{constructor(){super();
...
}}

A variant using ES6 classes as base class is shown here but the same works with old school constructor functions as well.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions