mirror of
https://github.com/bspeice/dtparse
synced 2024-11-13 17:38:09 -05:00
Improve error message to match dateutil
This commit is contained in:
parent
4acd072974
commit
e1c7c8424a
@ -955,7 +955,7 @@ impl Parser {
|
|||||||
if let Ok(val) = tokens[idx + 4].parse::<i32>() {
|
if let Ok(val) = tokens[idx + 4].parse::<i32>() {
|
||||||
ymd.append(val, &tokens[idx + 4], None)?;
|
ymd.append(val, &tokens[idx + 4], None)?;
|
||||||
} else {
|
} else {
|
||||||
return Err(ParseInternalError::ValueError("".to_owned()));
|
return Err(ParseInternalError::ValueError("Unknown string format".to_owned()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,9 @@ fn test_fuzz() {
|
|||||||
assert_eq!(parse("\x2D\x38\x31\x39\x34\x38\x34"), Err(ParseError::InvalidMonth));
|
assert_eq!(parse("\x2D\x38\x31\x39\x34\x38\x34"), Err(ParseError::InvalidMonth));
|
||||||
// Garbage in the third delimited field
|
// Garbage in the third delimited field
|
||||||
assert_eq!(parse("2..\x00\x000d\x00+\x010d\x01\x00\x00\x00+"),
|
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 default = NaiveDate::from_ymd(2016, 6, 29).and_hms(0, 0, 0);
|
||||||
let mut p = Parser::default();
|
let mut p = Parser::default();
|
||||||
let res = p.parse("\x0D\x31", None, None, false, false, Some(&default), false, HashMap::new()).unwrap();
|
let res = p.parse("\x0D\x31", None, None, false, false, Some(&default), false, HashMap::new()).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user