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

Properly initialize and return Error objects #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kevinburkeshyp
Copy link

Previously errors would be created like:

var err = new Error({message: 'foo'});

If you try to print this via console.log, you get the message:

Error: [object Object]

The constructor for error takes a string as the first argument, so instead of
passing a dictionary we just pass the string value.

Furthermore, instead of passing back bare dictionaries when inputs fail
validation, we pass back instances of Error objects, which have stack traces
attached, and would pass checks like (err instanceof Error).

Previously errors would be created like:

    var err = new Error({message: 'foo'});

If you try to print this via `console.log`, you get the message:

    Error: [object Object]

The constructor for error takes a string as the first argument, so instead of
passing a dictionary we just pass the string value.

Furthermore, instead of passing back bare dictionaries when inputs fail
validation, we pass back instances of Error objects, which have stack traces
attached, and would pass checks like (err instanceof Error).
@shvelo
Copy link

shvelo commented Apr 27, 2016

Running into this issue myself, please merge this

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

Successfully merging this pull request may close these issues.

3 participants