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

InvalidEncoding representation #177

Closed
dtolnay opened this issue Apr 28, 2017 · 0 comments
Closed

InvalidEncoding representation #177

dtolnay opened this issue Apr 28, 2017 · 0 comments

Comments

@dtolnay
Copy link
Collaborator

@dtolnay dtolnay commented Apr 28, 2017

It looks like this is used for a very limited set of situations. It should be possible to represent them in a nicer way than { desc: &'static str, detail: Option<String> }.

InvalidEncoding {
    desc: "string was not valid utf8",
    detail: None,
}
InvalidEncoding {
    desc: "error while decoding utf8 string",
    detail: Some(format!("Deserialize error: {}", err))
}
InvalidEncoding {
    desc: "invalid u8 when decoding bool",
    detail: Some(format!("Expected 0 or 1, got {}", value))
}
InvalidEncoding {
    desc: "Invalid char encoding",
    detail: None,
}
InvalidEncoding {
    desc: "invalid tag when decoding Option",
    detail: Some(format!("Expected 0 or 1, got {}", value))
}

Maybe something like:

InvalidUtf8
also InvalidUtf8...?
InvalidBool
InvalidChar
InvalidOption

with the relevant information in each case to build the error message.

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

Successfully merging a pull request may close this issue.

1 participant
You can’t perform that action at this time.