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

Custom errors for validators #11

Merged
merged 2 commits into from
Sep 21, 2017
Merged

Conversation

anti-social
Copy link
Contributor

No description provided.

src/errors.rs Outdated
@@ -85,6 +96,30 @@ impl Error {
ErrorPos((*pos.filename).clone(), pos.line, pos.line_offset),
message).into()
}

pub fn custom_error<T: StdError + 'static>(err: T)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why custom_error. I think it's custom everywhere in the rust ecosystem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of implementing custom at impl ::serde::de::Error for Error:

error[E0277]: the trait bound `std::string::String: std::error::Error` is not satisfied                   
  --> src/de.rs:73:28                                                                                     
   |                                                 
73 |                 return Err(Error::custom(format!("bad boolean {:?}", self.0)));                      
   |                            ^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `std::string::String`                                                                                            
   |                                                                                                      
   = note: required by `errors::Error::custom`

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can write it as de::Error::custom instead. Presumably, this will never happen outside of the quire library itself (i.e. having de::Error in scope as well as quire::Error)

@tailhook
Copy link
Owner

Otherwise looks fine.

@tailhook tailhook merged commit 78bf7f2 into tailhook:master Sep 21, 2017
@tailhook
Copy link
Owner

Thanks! v0.3.1 will be published as soon as travis finishes.

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.

None yet

2 participants