Merge pull request #376 from AnderEnder/remove-deprecated-error-description
Allow deprecated Error::description and replace it with a stub implementation.
This commit is contained in:
commit
6daed98412
|
@ -318,30 +318,25 @@ enum ParseErrorKind {
|
||||||
/// Same to `Result<T, ParseError>`.
|
/// Same to `Result<T, ParseError>`.
|
||||||
pub type ParseResult<T> = Result<T, ParseError>;
|
pub type ParseResult<T> = Result<T, ParseError>;
|
||||||
|
|
||||||
impl ParseError {
|
|
||||||
fn description(&self) -> &str {
|
|
||||||
match self.0 {
|
|
||||||
ParseErrorKind::OutOfRange => "input is out of range",
|
|
||||||
ParseErrorKind::Impossible => "no possible date and time matching input",
|
|
||||||
ParseErrorKind::NotEnough => "input is not enough for unique date and time",
|
|
||||||
ParseErrorKind::Invalid => "input contains invalid characters",
|
|
||||||
ParseErrorKind::TooShort => "premature end of input",
|
|
||||||
ParseErrorKind::TooLong => "trailing input",
|
|
||||||
ParseErrorKind::BadFormat => "bad or unsupported format string",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for ParseError {
|
impl fmt::Display for ParseError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
self.description().fmt(f)
|
match self.0 {
|
||||||
|
ParseErrorKind::OutOfRange => write!(f, "input is out of range"),
|
||||||
|
ParseErrorKind::Impossible => write!(f, "no possible date and time matching input"),
|
||||||
|
ParseErrorKind::NotEnough => write!(f, "input is not enough for unique date and time"),
|
||||||
|
ParseErrorKind::Invalid => write!(f, "input contains invalid characters"),
|
||||||
|
ParseErrorKind::TooShort => write!(f, "premature end of input"),
|
||||||
|
ParseErrorKind::TooLong => write!(f, "trailing input"),
|
||||||
|
ParseErrorKind::BadFormat => write!(f, "bad or unsupported format string"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
impl Error for ParseError {
|
impl Error for ParseError {
|
||||||
|
#[allow(deprecated)]
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
self.description()
|
"parser error, see to_string() for details"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -393,22 +393,17 @@ impl fmt::Display for Duration {
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct OutOfRangeError(());
|
pub struct OutOfRangeError(());
|
||||||
|
|
||||||
impl OutOfRangeError {
|
|
||||||
fn description(&self) -> &str {
|
|
||||||
"Source duration value is out of range for the target type"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for OutOfRangeError {
|
impl fmt::Display for OutOfRangeError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "{}", self.description())
|
write!(f, "Source duration value is out of range for the target type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
impl Error for OutOfRangeError {
|
impl Error for OutOfRangeError {
|
||||||
|
#[allow(deprecated)]
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
self.description()
|
"out of range error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue