-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Serialization errors can only be created from the Encoder
/Decoder
methods
#15036
Comments
This was referenced Jun 25, 2014
This might be somewhat addressable by having an method like |
cc @erickt |
apoelstra
added a commit
to apoelstra/rust
that referenced
this issue
Aug 1, 2014
A quick and dirty fix for rust-lang#15036 until we get serious decoder reform. Right now it is impossible for a Decodable to signal a decode error, for example if it has only finitely many allowed values, is a string which must be encoded a certain way, needs a valid checksum, etc. For example in the libuuid implementation of Decodable an Option is unwrapped, meaning that a decode of a malformed UUID will cause the task to fail. Since this adds a method to the `Decoder` trait, all users will need to update their implementations to add it. The strategy used for the current implementations for JSON and EBML is to add a new entry to the error enum `ApplicationError(String)` which stores the string provided to `.error()`. [breaking-change]
bors
added a commit
that referenced
this issue
Aug 1, 2014
A quick and dirty fix for #15036 until we get serious decoder reform. Right now it is impossible for a `Decodable` to signal a decode error, for example if it has only finitely many allowed values, is a string which must be encoded a certain way, needs a valid checksum, etc. For example in the `libuuid` implementation of `Decodable` an `Option` is unwrapped, meaning that a decode of a malformed UUID will cause the task to fail.
This was fixed for |
lnicola
pushed a commit
to lnicola/rust
that referenced
this issue
Jun 19, 2023
…=Veykril internal: Give ConstBlockId and InTypeConstId named Location types cc rust-lang/rust-analyzer#14932
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is no way for a custom generic
Decodable
/Encodable
instance (compatible with#[deriving]
other) to return a new error since it's completely generic, that is,It might be nice if there was a
E: Error
trait (or some such) thatderiving
used, which has some basic constructors.The text was updated successfully, but these errors were encountered: