Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.
/ errors Public archive

Add code property to errors #39

@vweevers

Description

@vweevers

For example:

if (err.code === 'ERR_NOT_FOUND') // ..

This will allow us to:

  • Change error messages without a major bump. Going forward, the semver contract will be on code.
  • Change the test suites of levelup and abstract-leveldown to check expected errors by code, making it easier to align errors.
  • Return specific errors from C++, because it aligns well with napi_create_error(env, code, ...). E.g. leveldown can return a ERR_NOT_FOUND natively without the need for further wrapping in JS (although initially we'll still need that for backwards compat).

TBD:

  1. Does this remove the need for the current error types defined here?
  2. If not, will we need a mapping of codes to types?
  3. Should we restrict the codes to a known set, or allow modules (like leveldown) to return arbitrary codes?
  4. Should the codes have a certain prefix, like ERR_LEVEL_?

Ref Level/community#58

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions