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

use enum ParseError for errors instead of strings #5

Merged
merged 1 commit into from Aug 1, 2014

Conversation

@seanmonstar
Copy link
Contributor

seanmonstar commented Jul 31, 2014

Strings make things harder. When trying to decide if my error_handler should eat the error or not, the compiler won't notice if I typo an error message. And if the message changes, the compiler won't warn me about a non-existent enum variant.

With an enum, I can match for certains errors. I made the Show implementation mirror the text of the errors from before, in case they were used to show in a Browser Console or something. This also allows for the messages to be adjusted slightly, while leaving the variant alone.

@SimonSapin
Copy link
Member

SimonSapin commented Aug 1, 2014

Thanks for contributing! Please add #[deriving(PartialEq, Eq, Clone)] on pub enum ParseError. r+ with that, assuming it fixes the Travis build.

@seanmonstar
Copy link
Contributor Author

seanmonstar commented Aug 1, 2014

Ah sure, I didn't realize that was additional tests beyond cargo test. I've added those deriving, and also noticed that ErrorHandler and parse_error were still using &str, so I converted all those into variants as well.

./doc.sh --test passed locally, so I believe travis should pass.

SimonSapin added a commit that referenced this pull request Aug 1, 2014
use enum ParseError for errors instead of strings
@SimonSapin SimonSapin merged commit 3d54552 into servo:master Aug 1, 2014
1 check passed
1 check passed
continuous-integration/travis-ci The Travis CI build passed
Details
@SimonSapin
Copy link
Member

SimonSapin commented Aug 1, 2014

Merged, thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.