Skip to content

generateError should generate own type of Errors #455

Closed

Description

@kapouer

Hi,
orm should throw its own type of Errors.
Only distinguishing by err.code is not enough - some other layers of the application might throw the same codes.
This is related to #206 - and thanks to this, it is almost trivial now.

Activity

  1. kapouer commented on Feb 19, 2014

    @kapouer
    ContributorAuthor
  2. dresende commented on Feb 23, 2014

    @dresende
    Owner

    👍

  3. added a commit that references this issue on Feb 23, 2014
  4. dresende commented on Feb 23, 2014

    @dresende
    Owner

    Please comment, I don't have much time. Will current code somewhat break? We should add some kind of tests.

  5. kapouer commented on Feb 23, 2014

    @kapouer
    ContributorAuthor

    I can't think of a way the "client" code would break, since at worst, people doing checks against err.code won't be disappointed, and people doing err instanceof Error (this is nonsense) will get the same behavior as well.
    Oh you forgot the "name" property: it is very useful to set this.name = "ORMError" - it allows checking the type without having to require the file it is declared in.

  6. dxg commented on Feb 24, 2014

    @dxg
    Collaborator

    The 7776339 solution had an incorrect .stack and the way errors were constructed was a bit unintuitive. I'm not really sure if we need numerical error codes at all for anything, but they have to stick around for historical reasons. Anyways, I reimplemented it with all the bells and whistles, as well as an accurate stack & tests.

  7. added this to the v2.1.4 milestone on Feb 24, 2014
  8. dresende commented on Feb 24, 2014

    @dresende
    Owner

    👍

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

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions