Skip to content

Conversation

@andineck
Copy link

until now errors were always string. this commit changes this to error
Objects, with the intention to be able to programmatically handle
errors better (without string parsing).

Example Use Case: Crawling a website and checking if links are valid.
Current State: when a link points to a ressource which is not
available, it returns an error with a string containing 404. State with
this commit, it returns an error with an errorType, statusCode etc,
which can be processed easily.

until now errors were always string. this commit changes this to error
Objects, with the intention to be able to programmatically handle
errors better (without string parsing).

Example Use Case: Crawling a website and checking if links are valid.
Current State: when a link points to a ressource which is not
available, it returns an error with a string containing 404. State with
this commit, it returns an error with an errorType, statusCode etc,
which can be processed easily.
@rchipka
Copy link
Owner

rchipka commented May 28, 2016

Error codes work well for HTTP errors, but the error system should be consistent. I agree with implementing a better error system, but non-HTTP errors should use the same system. This means that errors like failed logins and no results for selectors should also throw an error object with an error code.

Also, try not to use Object.assign so the code works on ES5 platforms too.

@rchipka
Copy link
Owner

rchipka commented Nov 25, 2016

Discussion in #135

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.

2 participants