In Parse(), throw FormatException instead of ArgumentOutOfRangeException.
authorAtsushi Eno <atsushi@ximian.com>
Thu, 14 Apr 2011 08:28:35 +0000 (17:28 +0900)
committerAtsushi Eno <atsushi@ximian.com>
Thu, 14 Apr 2011 08:28:35 +0000 (17:28 +0900)
mcs/class/corlib/System/DateTimeOffset.cs

index ffb58892a4e0852e9b992ae97f4ae27cebb599e1..53d4cedac0e7a84a303ee9cd916d736bb9dbe64c 100644 (file)
@@ -296,11 +296,15 @@ namespace System
                        DateTime d;
                        DateTimeOffset dto;
                        Exception exception = null;
-                       if (!DateTime.CoreParse (input, formatProvider, styles, out d, out dto, true, ref exception))
-                               throw exception;
+                       try {
+                               if (!DateTime.CoreParse (input, formatProvider, styles, out d, out dto, true, ref exception))
+                                       throw exception;
+                       } catch (ArgumentOutOfRangeException ex) {
+                               throw new FormatException ("The UTC representation falls outside the 1-9999 year range", ex);
+                       }
 
                        if (d.Ticks != 0 && dto.Ticks == 0)
-                               throw new ArgumentOutOfRangeException ("The UTC representation falls outside the 1-9999 year range");
+                               throw new FormatException ("The UTC representation falls outside the 1-9999 year range");
 
                        return dto;
                }