Skip to content

Properly initialize and return Error objects#103

Open
kevinburkeshyp wants to merge 1 commit intosailshq:masterfrom
kevinburkeshyp:init-errors
Open

Properly initialize and return Error objects#103
kevinburkeshyp wants to merge 1 commit intosailshq:masterfrom
kevinburkeshyp:init-errors

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