From e1c7c8424aee758088680f4f07a4b6ecc8319fda Mon Sep 17 00:00:00 2001 From: Mike Meehan Date: Wed, 18 Jul 2018 23:03:53 -0400 Subject: [PATCH] Improve error message to match dateutil --- src/lib.rs | 2 +- src/tests/fuzzing.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 680ea7c..6589e89 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -955,7 +955,7 @@ impl Parser { if let Ok(val) = tokens[idx + 4].parse::() { ymd.append(val, &tokens[idx + 4], None)?; } else { - return Err(ParseInternalError::ValueError("".to_owned())); + return Err(ParseInternalError::ValueError("Unknown string format".to_owned())); } } diff --git a/src/tests/fuzzing.rs b/src/tests/fuzzing.rs index 2508f02..e204d17 100644 --- a/src/tests/fuzzing.rs +++ b/src/tests/fuzzing.rs @@ -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();