#QUALITY by stefan
authorStefan Vogel <sv@exept.de>
Fri, 20 May 2016 10:02:41 +0200
changeset 19896 32e62e396575
parent 19895 107644108896
child 19897 cb8cea59de5c
#QUALITY by stefan class: Date changed: #newDay:year: #readFrom:format: #readFrom:format:language:onError: #year:month:day: more specific information in ConversionError
Date.st
--- a/Date.st	Fri May 20 10:02:25 2016 +0200
+++ b/Date.st	Fri May 20 10:02:41 2016 +0200
@@ -336,16 +336,15 @@
 
     |monthAndDay|
 
-    (dayInYear between:1 and:365) ifFalse:[
-        (dayInYear == 366 and:[self leapYear:year]) ifFalse:[
-            "
-             this error is triggered, when you try to create a
-             day from an invalid day-in-year; 
-             for example, 366 in a non-leap year.
-             I don't know, if ST-80 wraps to the next year(s) in this case.
-            "
-            ^ self conversionErrorSignal raiseErrorString:' - invalid day in year'.
-        ]
+    ((dayInYear between:1 and:365) 
+     or:[dayInYear == 366 and:[self leapYear:year]]) ifFalse:[
+        "
+         this error is triggered, when you try to create a
+         day from an invalid day-in-year; 
+         for example, 366 in a non-leap year.
+         I don't know, if ST-80 wraps to the next year(s) in this case.
+        "
+        ^ self conversionErrorSignal raiseErrorString:' - Date: invalid day in year'.
     ].
     monthAndDay := self monthAndDayFromDayInYear:dayInYear forYear:year.
     ^ self basicNew year:year month:(monthAndDay at:1) day:(monthAndDay at:2)  
@@ -406,7 +405,7 @@
     ^ self 
         readFrom:aStringOrStream
         format:aSqueakFormatArrayOrFormatString 
-        onError:[ self conversionErrorSignal raise ]
+        onError:[ self conversionErrorSignal raiseWith:aStringOrStream errorString:' - invalid Date' ]
 
     "
      Date readFrom:'19:11:1999' format:#( 1 2 3 )
@@ -515,7 +514,7 @@
                     ] ifFalse:[somePartAssoc key == #dayOfYear ifTrue:[
                         dayOfYear := somePartAssoc value.
                     ] ifFalse:[
-                        self conversionErrorSignal raiseErrorString:' - unexpected date part'
+                        self conversionErrorSignal raiseWith:aStringOrStream errorString:' - unexpected date part'
                     ]]]].
                 ] ifFalse:[
                     fc == Character space ifTrue:[
@@ -777,7 +776,7 @@
     ].
     year class ~= SmallInteger ifTrue:[
         "we support a lot of future, but LargeInteger years fail in #isLeapYear"
-        self conversionErrorSignal raiseErrorString:' - invalid year (way too large)'.
+        self conversionErrorSignal raiseWith:year errorString:' - invalid year in Date (way too large)'.
     ].    
     month isInteger ifTrue:[
         monthIndex := month
@@ -926,6 +925,7 @@
     "
 ! !
 
+
 !Date class methodsFor:'change & update'!
 
 update:something with:aParameter from:changedObject
@@ -1897,6 +1897,7 @@
     "Modified: 8.10.1996 / 19:25:39 / cg"
 ! !
 
+
 !Date class methodsFor:'private'!
 
 dayAbbrevsForLanguage:languageOrNilForDefault
@@ -2113,6 +2114,7 @@
     "
 ! !
 
+
 !Date methodsFor:'Compatibility-ANSI'!
 
 dayOfWeek
@@ -3272,6 +3274,7 @@
 ! !
 
 
+
 !Date methodsFor:'obsolete'!
 
 asAbsoluteTime
@@ -3342,6 +3345,7 @@
     ^ self addDays:days
 ! !
 
+
 !Date methodsFor:'printing & storing'!
 
 addPrintBindingsTo:aDictionary