A new error variant was recently added: Error::OptionIsNone. This variant allows Option types to be handled without an explicit call to unwrap() by using ok_or(Error::OptionIsNone)?, which is particularly handy when you expect the value to be Some but don't want to panic if it's not.
The problem is that there is currently no context attached to the error, making debugging more difficult than it needs to be.
TODO: Add context as a String (ie. Error::OptionIsNone(String)) and replace all remaining Option unwraps with ok_or and OptionIsNone error (where appropriate). The String should indicate the origin of the error, ie. for what value did we expect Some?
A new error variant was recently added:
Error::OptionIsNone
. This variant allowsOption
types to be handled without an explicit call tounwrap()
by usingok_or(Error::OptionIsNone)?
, which is particularly handy when you expect the value to beSome
but don't want to panic if it's not.The problem is that there is currently no context attached to the error, making debugging more difficult than it needs to be.
TODO: Add context as a
String
(ie.Error::OptionIsNone(String)
) and replace all remainingOption
unwraps withok_or
andOptionIsNone
error (where appropriate). TheString
should indicate the origin of the error, ie. for what value did we expectSome
?