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

introduce error objects #90

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

introduce error objects #90

wants to merge 1 commit into from

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