Improve error message to match dateutil

pull/14/head
Mike Meehan 2018-07-18 23:03:53 -04:00
parent 4acd072974
commit e1c7c8424a
2 changed files with 4 additions and 2 deletions

View File

@ -955,7 +955,7 @@ impl Parser {
if let Ok(val) = tokens[idx + 4].parse::<i32>() {
ymd.append(val, &tokens[idx + 4], None)?;
} else {
return Err(ParseInternalError::ValueError("".to_owned()));
return Err(ParseInternalError::ValueError("Unknown string format".to_owned()));
}
}

View File

@ -12,7 +12,9 @@ fn test_fuzz() {
assert_eq!(parse("\x2D\x38\x31\x39\x34\x38\x34"), Err(ParseError::InvalidMonth));
// Garbage in the third delimited field
assert_eq!(parse("2..\x00\x000d\x00+\x010d\x01\x00\x00\x00+"),
Err(ParseError::InternalError(ParseInternalError::ValueError("".to_owned()))));
Err(ParseError::InternalError(ParseInternalError::ValueError("Unknown string format".to_owned()))));
// OverflowError: Python int too large to convert to C long
// assert_eq!(parse("8888884444444888444444444881"), Err(ParseError::AmPmWithoutHour));
let default = NaiveDate::from_ymd(2016, 6, 29).and_hms(0, 0, 0);
let mut p = Parser::default();
let res = p.parse("\x0D\x31", None, None, false, false, Some(&default), false, HashMap::new()).unwrap();