Skip to content

Conversation

ianwremmel
Copy link

Still needs some tests, but much more robust than #4.

  1. extend() now accepts an options object as alternative to the subTypeName and errorCode parameters.

  2. Decreases emphasis on HTTP-related errors. (instead of passing errorCode, add {properties: {code: <code>}} to the options object.

  3. Adds ability to provide alternate toString().

  4. Adds parseFn(), which can do additional processing on the SubType constructor argument. I'm primarily envisioning it as a way to wrap http error responses with an Error:

    if (res.statusCode === 404) {
      throw new HttpNotFoundError(res);
    }
  5. Just like Make monkeypatching optional #4, makes monkeypatching optional.

…; make name, message non-enumerable props

toString() does not work consistently so rely on parseFn to set message in a way the native toString() will render it

parseFn needs to be on the prototype so parent implementations can be invoked from subclasses

make name and message non-enumerable so they do not get double-rendered when calling console.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant