common error reporter
authorClaus Gittinger <cg@exept.de>
Tue, 03 Feb 1998 20:22:21 +0100
changeset 819 e358c08e45ea
parent 818 cd88643119dc
child 820 d01d777e2bb3
common error reporter
WinIconRdr.st
WindowsIconReader.st
--- a/WinIconRdr.st	Tue Feb 03 19:11:12 1998 +0100
+++ b/WinIconRdr.st	Tue Feb 03 20:22:21 1998 +0100
@@ -10,8 +10,6 @@
  hereby transferred.
 "
 
-'From Smalltalk/X, Version:3.2.1 on 21-oct-1997 at 5:07:02 pm'                  !
-
 ImageReader subclass:#WindowsIconReader
 	instanceVariableNames:''
 	classVariableNames:''
@@ -128,28 +126,28 @@
 
     d == 8 ifTrue:[
         (self class loadBMP8Width:w height:h compression:c from:aStream into:data) ifFalse:[
-            'WinIconReader [warning]: read/decompression failed' infoPrintNL.
+            self fileFormatError:'read/decompression failed'.
             ^ false
         ].
         ^ true
     ].
     d == 4 ifTrue:[
         (self class loadBMP4to8Width:w height:h compression:c from:aStream into:data) ifFalse:[
-            'WinIconReader [warning]: read/decompression failed' infoPrintNL.
+            self fileFormatError:'read/decompression failed'.
             ^ false
         ].
         ^ true
     ].
     d == 2 ifTrue:[
         (self class loadBMP2to8Width:w height:h from:aStream into:data) ifFalse:[
-            'WinIconReader [warning]: read failed' infoPrintNL.
+            self fileFormatError:'read failed'.
             ^ false
         ].
         ^ true
     ].
     d == 1 ifTrue:[
         (self class loadBMP1to8Width:w height:h from:aStream into:data) ifFalse:[
-            'WinIconReader [warning]: read failed' infoPrintNL.
+            self fileFormatError:'read failed'.
             ^ false
         ].
         ^ true
@@ -168,7 +166,7 @@
 
         1 to:height do:[:row |
             (aStream nextBytes:fileBytesPerRow into:buff) ~~ fileBytesPerRow ifTrue:[
-                'WinIconReader [warning]: read failed' infoPrintNL.
+                self fileFormatError:'read failed'.
                 ^ false
             ].
             data replaceFrom:idx to:idx+imgBytesPerRow-1 with:buff.
@@ -176,10 +174,11 @@
         ].
         ^ true
     ].
-    'WinIconReader [warning]: unsupported depth:' infoPrint. d infoPrintNL.
+    self fileFormatError:('unsupported depth:' , d printString).
+    ^ false
 
-    "Created: 17.9.1995 / 18:48:11 / claus"
-    "Modified: 19.10.1997 / 00:01:56 / cg"
+    "Created: / 17.9.1995 / 18:48:11 / claus"
+    "Modified: / 3.2.1998 / 20:21:16 / cg"
 ! !
 
 !WindowsIconReader methodsFor:'reading from file'!
@@ -222,8 +221,7 @@
         inDepth := 2 "header at:11". "where is it"
     ] ifFalse:[
         (header startsWith:#(67 73)) ifTrue:[     "CI"
-            self error:'unsupported format: CI'.
-            ^ nil.
+            ^ self fileFormatError:'unsupported format: CI'.
         ] ifFalse:[
             aStream nextBytes:(8r110-16) into:header startingAt:17.
             width := header at:8r101.
@@ -309,8 +307,8 @@
      v displayOpaqueForm:(f magnifyBy:2@2) x:5 y:5
     "
 
-    "Modified: 17.9.1995 / 18:49:24 / claus"
-    "Modified: 24.2.1997 / 12:11:39 / cg"
+    "Modified: / 17.9.1995 / 18:49:24 / claus"
+    "Modified: / 3.2.1998 / 20:17:13 / cg"
 !
 
 fromStream:aStream 
@@ -326,8 +324,7 @@
     fileSize := aStream fileSize.
 
     fileSize < 16 ifTrue:[
-        'WinIconReader [warning]: short file' infoPrintNL.
-        ^ nil
+        ^ self fileFormatError:'short file'.
     ].
 
     header := ByteArray uninitializedNew:4.
@@ -372,18 +369,17 @@
 "/        'WinIconReader [info]: Win3.x ICO format' infoPrintNL.
         ^ self fromWindowsICOStream:aStream
     ].
-    'WinIconReader [warning]: format not supported:' infoPrint.
-    ((header at:1) printStringRadix:16) infoPrint.
-    ' ' infoPrint.
-    ((header at:2) printStringRadix:16) infoPrintNL.
-    ^ nil
+    ^ self fileFormatError:('format not supported:'
+                            , ((header at:1) printStringRadix:16)
+                            , ' ' 
+                            , ((header at:2) printStringRadix:16)).
 
     "
      Image fromFile:'/phys/clam//LocalLibrary/Images/OS2_icons/dos.ico'
     "
 
-    "Modified: 17.9.1995 / 18:59:07 / claus"
-    "Modified: 24.2.1997 / 12:12:41 / cg"
+    "Modified: / 17.9.1995 / 18:59:07 / claus"
+    "Modified: / 3.2.1998 / 20:18:14 / cg"
 !
 
 fromWindowsBMPFile: aFilename 
@@ -477,8 +473,7 @@
             "/ dataStart := header wordAt:(16r0A + 1) MSB:false.
             dataStart := nil.
         ] ifFalse:[
-            'WinIconReader [warning]: unknown format' infoPrintNL.
-            ^ nil
+            ^ self fileFormatError:'unknown format'.
         ].
     ].
 
@@ -509,22 +504,19 @@
         compression == 1 ifTrue:[
             "/ RLE8 - must be depth-8
             inDepth ~~ 8 ifTrue:[
-                'WinIconReader [warning]: RLE8 compression only allowed with depth8 images' infoPrintNL.
-                ^ nil
+                ^ self fileFormatError:'RLE8 compression only supported with depth8 images'.
             ].
         ].
         compression == 2 ifTrue:[
             "/ RLE4 - must be depth-4
             inDepth ~~ 4 ifTrue:[
-                'WinIconReader [warning]: RLE4 compression only allowed with depth4 images' infoPrintNL.
-                ^ nil
+                ^ self fileFormatError:'RLE4 compression only supported with depth4 images'.
             ].
         ].
     ].
 
     inPlanes ~~ 1 ifTrue:[
-        'WinIconReader [warning]: only 1 plane images supported' infoPrintNL.
-        ^ nil
+        ^ self fileFormatError:'only 1 plane images supported'.
     ].
 
     dataStart notNil ifTrue:[
@@ -556,8 +548,8 @@
     bitsPerSample := #(8).
     colorMap := Colormap redVector:rMap greenVector:gMap blueVector:bMap.
 
-    "Modified: 17.9.1995 / 18:48:46 / claus"
-    "Modified: 24.4.1997 / 22:09:23 / cg"
+    "Modified: / 17.9.1995 / 18:48:46 / claus"
+    "Modified: / 3.2.1998 / 20:19:41 / cg"
 !
 
 fromWindowsICOFile:aFilename 
@@ -798,6 +790,6 @@
 !WindowsIconReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/Attic/WinIconRdr.st,v 1.37 1997-10-21 18:27:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/Attic/WinIconRdr.st,v 1.38 1998-02-03 19:22:21 cg Exp $'
 ! !
 WindowsIconReader initialize!
--- a/WindowsIconReader.st	Tue Feb 03 19:11:12 1998 +0100
+++ b/WindowsIconReader.st	Tue Feb 03 20:22:21 1998 +0100
@@ -10,8 +10,6 @@
  hereby transferred.
 "
 
-'From Smalltalk/X, Version:3.2.1 on 21-oct-1997 at 5:07:02 pm'                  !
-
 ImageReader subclass:#WindowsIconReader
 	instanceVariableNames:''
 	classVariableNames:''
@@ -128,28 +126,28 @@
 
     d == 8 ifTrue:[
         (self class loadBMP8Width:w height:h compression:c from:aStream into:data) ifFalse:[
-            'WinIconReader [warning]: read/decompression failed' infoPrintNL.
+            self fileFormatError:'read/decompression failed'.
             ^ false
         ].
         ^ true
     ].
     d == 4 ifTrue:[
         (self class loadBMP4to8Width:w height:h compression:c from:aStream into:data) ifFalse:[
-            'WinIconReader [warning]: read/decompression failed' infoPrintNL.
+            self fileFormatError:'read/decompression failed'.
             ^ false
         ].
         ^ true
     ].
     d == 2 ifTrue:[
         (self class loadBMP2to8Width:w height:h from:aStream into:data) ifFalse:[
-            'WinIconReader [warning]: read failed' infoPrintNL.
+            self fileFormatError:'read failed'.
             ^ false
         ].
         ^ true
     ].
     d == 1 ifTrue:[
         (self class loadBMP1to8Width:w height:h from:aStream into:data) ifFalse:[
-            'WinIconReader [warning]: read failed' infoPrintNL.
+            self fileFormatError:'read failed'.
             ^ false
         ].
         ^ true
@@ -168,7 +166,7 @@
 
         1 to:height do:[:row |
             (aStream nextBytes:fileBytesPerRow into:buff) ~~ fileBytesPerRow ifTrue:[
-                'WinIconReader [warning]: read failed' infoPrintNL.
+                self fileFormatError:'read failed'.
                 ^ false
             ].
             data replaceFrom:idx to:idx+imgBytesPerRow-1 with:buff.
@@ -176,10 +174,11 @@
         ].
         ^ true
     ].
-    'WinIconReader [warning]: unsupported depth:' infoPrint. d infoPrintNL.
+    self fileFormatError:('unsupported depth:' , d printString).
+    ^ false
 
-    "Created: 17.9.1995 / 18:48:11 / claus"
-    "Modified: 19.10.1997 / 00:01:56 / cg"
+    "Created: / 17.9.1995 / 18:48:11 / claus"
+    "Modified: / 3.2.1998 / 20:21:16 / cg"
 ! !
 
 !WindowsIconReader methodsFor:'reading from file'!
@@ -222,8 +221,7 @@
         inDepth := 2 "header at:11". "where is it"
     ] ifFalse:[
         (header startsWith:#(67 73)) ifTrue:[     "CI"
-            self error:'unsupported format: CI'.
-            ^ nil.
+            ^ self fileFormatError:'unsupported format: CI'.
         ] ifFalse:[
             aStream nextBytes:(8r110-16) into:header startingAt:17.
             width := header at:8r101.
@@ -309,8 +307,8 @@
      v displayOpaqueForm:(f magnifyBy:2@2) x:5 y:5
     "
 
-    "Modified: 17.9.1995 / 18:49:24 / claus"
-    "Modified: 24.2.1997 / 12:11:39 / cg"
+    "Modified: / 17.9.1995 / 18:49:24 / claus"
+    "Modified: / 3.2.1998 / 20:17:13 / cg"
 !
 
 fromStream:aStream 
@@ -326,8 +324,7 @@
     fileSize := aStream fileSize.
 
     fileSize < 16 ifTrue:[
-        'WinIconReader [warning]: short file' infoPrintNL.
-        ^ nil
+        ^ self fileFormatError:'short file'.
     ].
 
     header := ByteArray uninitializedNew:4.
@@ -372,18 +369,17 @@
 "/        'WinIconReader [info]: Win3.x ICO format' infoPrintNL.
         ^ self fromWindowsICOStream:aStream
     ].
-    'WinIconReader [warning]: format not supported:' infoPrint.
-    ((header at:1) printStringRadix:16) infoPrint.
-    ' ' infoPrint.
-    ((header at:2) printStringRadix:16) infoPrintNL.
-    ^ nil
+    ^ self fileFormatError:('format not supported:'
+                            , ((header at:1) printStringRadix:16)
+                            , ' ' 
+                            , ((header at:2) printStringRadix:16)).
 
     "
      Image fromFile:'/phys/clam//LocalLibrary/Images/OS2_icons/dos.ico'
     "
 
-    "Modified: 17.9.1995 / 18:59:07 / claus"
-    "Modified: 24.2.1997 / 12:12:41 / cg"
+    "Modified: / 17.9.1995 / 18:59:07 / claus"
+    "Modified: / 3.2.1998 / 20:18:14 / cg"
 !
 
 fromWindowsBMPFile: aFilename 
@@ -477,8 +473,7 @@
             "/ dataStart := header wordAt:(16r0A + 1) MSB:false.
             dataStart := nil.
         ] ifFalse:[
-            'WinIconReader [warning]: unknown format' infoPrintNL.
-            ^ nil
+            ^ self fileFormatError:'unknown format'.
         ].
     ].
 
@@ -509,22 +504,19 @@
         compression == 1 ifTrue:[
             "/ RLE8 - must be depth-8
             inDepth ~~ 8 ifTrue:[
-                'WinIconReader [warning]: RLE8 compression only allowed with depth8 images' infoPrintNL.
-                ^ nil
+                ^ self fileFormatError:'RLE8 compression only supported with depth8 images'.
             ].
         ].
         compression == 2 ifTrue:[
             "/ RLE4 - must be depth-4
             inDepth ~~ 4 ifTrue:[
-                'WinIconReader [warning]: RLE4 compression only allowed with depth4 images' infoPrintNL.
-                ^ nil
+                ^ self fileFormatError:'RLE4 compression only supported with depth4 images'.
             ].
         ].
     ].
 
     inPlanes ~~ 1 ifTrue:[
-        'WinIconReader [warning]: only 1 plane images supported' infoPrintNL.
-        ^ nil
+        ^ self fileFormatError:'only 1 plane images supported'.
     ].
 
     dataStart notNil ifTrue:[
@@ -556,8 +548,8 @@
     bitsPerSample := #(8).
     colorMap := Colormap redVector:rMap greenVector:gMap blueVector:bMap.
 
-    "Modified: 17.9.1995 / 18:48:46 / claus"
-    "Modified: 24.4.1997 / 22:09:23 / cg"
+    "Modified: / 17.9.1995 / 18:48:46 / claus"
+    "Modified: / 3.2.1998 / 20:19:41 / cg"
 !
 
 fromWindowsICOFile:aFilename 
@@ -798,6 +790,6 @@
 !WindowsIconReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/WindowsIconReader.st,v 1.37 1997-10-21 18:27:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/WindowsIconReader.st,v 1.38 1998-02-03 19:22:21 cg Exp $'
 ! !
 WindowsIconReader initialize!