Index: lib/src/http_date.dart |
diff --git a/lib/src/http_date.dart b/lib/src/http_date.dart |
index 7d46d553eda30676d2916fd17f68c06c46beb70b..959053649d845b17ef1c86c1cde7e11e881ec712 100644 |
--- a/lib/src/http_date.dart |
+++ b/lib/src/http_date.dart |
@@ -6,6 +6,8 @@ library http_parser.http_date; |
import 'package:string_scanner/string_scanner.dart'; |
+import 'utils.dart'; |
+ |
const _WEEKDAYS = const ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; |
const _MONTHS = const ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", |
"Sep", "Oct", "Nov", "Dec"]; |
@@ -48,7 +50,7 @@ String formatHttpDate(DateTime date) { |
/// 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3). It will |
/// throw a [FormatException] if [date] is invalid. |
DateTime parseHttpDate(String date) { |
- try { |
+ return wrapFormatException("HTTP date", date, () { |
var scanner = new StringScanner(date); |
if (scanner.scan(_longWeekdayRegExp)) { |
@@ -96,9 +98,7 @@ DateTime parseHttpDate(String date) { |
scanner.expectDone(); |
return _makeDateTime(year, month, day, time); |
- } on FormatException catch (error) { |
- throw new FormatException('Invalid HTTP date "$date": ${error.message}'); |
- } |
+ }); |
} |
/// Parses a short-form month name to a form accepted by [DateTime]. |