6270
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
|
|
14 |
|
6271
|
15 |
"{ Package: 'stx:libbasic' }"
|
6270
|
16 |
|
|
17 |
Object subclass:#OSErrorHolder
|
6280
|
18 |
instanceVariableNames:'errorSymbol errorCategory'
|
6271
|
19 |
classVariableNames:'Signals OSErrorSignal'
|
6270
|
20 |
poolDictionaries:''
|
6271
|
21 |
category:'OS-Support'
|
6270
|
22 |
!
|
|
23 |
|
|
24 |
!OSErrorHolder class methodsFor:'documentation'!
|
|
25 |
|
|
26 |
copyright
|
|
27 |
"
|
|
28 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger
|
|
29 |
All Rights Reserved
|
|
30 |
|
|
31 |
This software is furnished under a license and may be used
|
|
32 |
only in accordance with the terms of that license and with the
|
|
33 |
inclusion of the above copyright notice. This software may not
|
|
34 |
be provided or otherwise made available to, or used by, any
|
|
35 |
other person. No title to or ownership of the software is
|
|
36 |
hereby transferred.
|
|
37 |
"
|
|
38 |
|
|
39 |
|
|
40 |
!
|
|
41 |
|
|
42 |
documentation
|
|
43 |
"
|
6271
|
44 |
This class represents low level operating system errors.
|
|
45 |
We do not use error numbers, because there may be different errnos
|
|
46 |
for the same error on different systems.
|
6270
|
47 |
|
6271
|
48 |
[instance variables:]
|
|
49 |
errorSymbol symbol associated with this error
|
|
50 |
errorCategory symbol defining the error category.
|
|
51 |
This is in fact a symbol that returns a
|
|
52 |
Signal when sent to myself.
|
6270
|
53 |
|
6271
|
54 |
While the errorSymbol may be different on different platforms,
|
|
55 |
the errorCategories (which refer to the Signals that will be raised)
|
|
56 |
are identical.
|
|
57 |
You can get an OS independent error message for an error by sending
|
|
58 |
#errorCategoryString.
|
|
59 |
|
|
60 |
[author:]
|
|
61 |
Stefan Vogel
|
|
62 |
|
|
63 |
[see also:]
|
|
64 |
OperatingSystem
|
6270
|
65 |
"
|
|
66 |
! !
|
|
67 |
|
6294
|
68 |
!OSErrorHolder class methodsFor:'Signal constants'!
|
|
69 |
|
6297
|
70 |
allocRetrySignal
|
|
71 |
^ Signals at:#allocRetrySignal
|
|
72 |
!
|
|
73 |
|
|
74 |
badAccessorSignal
|
|
75 |
^ Signals at:#badAccessorSignal
|
|
76 |
!
|
|
77 |
|
|
78 |
badArgumentsSignal
|
|
79 |
^ Signals at:#badArgumentsSignal
|
|
80 |
!
|
|
81 |
|
|
82 |
existingReferentSignal
|
|
83 |
^ Signals at:#existingReferentSignal
|
|
84 |
!
|
|
85 |
|
|
86 |
illegalOperationSignal
|
|
87 |
^ Signals at:#illegalOperationSignal
|
|
88 |
!
|
|
89 |
|
|
90 |
inaccessibleSignal
|
|
91 |
^ Signals at:#inaccessibleSignal
|
|
92 |
!
|
|
93 |
|
|
94 |
inappropriateOperationSignal
|
|
95 |
^ Signals at:#inappropriateOperationSignal
|
|
96 |
!
|
|
97 |
|
|
98 |
inappropriateReferentSignal
|
|
99 |
^ Signals at:#inappropriateReferentSignal
|
|
100 |
!
|
|
101 |
|
6294
|
102 |
invalidArgumentsSignal
|
|
103 |
"return the signal for invalid arguments (e.g. right class, wrong value)."
|
|
104 |
|
|
105 |
^ OsInvalidArgumentsError
|
6297
|
106 |
!
|
|
107 |
|
|
108 |
needRetrySignal
|
|
109 |
^ Signals at:#needRetrySignal
|
|
110 |
!
|
|
111 |
|
|
112 |
noDataSignal
|
|
113 |
^ Signals at:#noDataSignal
|
|
114 |
!
|
|
115 |
|
|
116 |
noMemorySignal
|
|
117 |
^ Signals at:#noMemorySignal
|
|
118 |
!
|
|
119 |
|
|
120 |
noPermissionsSignal
|
|
121 |
^ Signals at:#noPermissionsSignal
|
|
122 |
!
|
|
123 |
|
|
124 |
noResourcesSignal
|
|
125 |
^ Signals at:#noResourcesSignal
|
|
126 |
!
|
|
127 |
|
|
128 |
nonexistentSignal
|
|
129 |
"return the signal for non existing referents (i.e. device, file etc.)."
|
|
130 |
|
|
131 |
^ Signals at:#nonexistentSignal
|
|
132 |
!
|
|
133 |
|
|
134 |
notReadySignal
|
|
135 |
^ Signals at:#notReadySignal
|
|
136 |
!
|
|
137 |
|
|
138 |
peerFaultSignal
|
|
139 |
^ Signals at:#peerFaultSignal
|
|
140 |
!
|
|
141 |
|
|
142 |
rangeErrorSignal
|
|
143 |
^ Signals at:#rangeErrorSignal
|
|
144 |
!
|
|
145 |
|
|
146 |
transferFaultSignal
|
|
147 |
^ Signals at:#transferFaultSignal
|
|
148 |
!
|
|
149 |
|
|
150 |
transientErrorSignal
|
|
151 |
^ Signals at:#transientErrorSignal
|
|
152 |
!
|
|
153 |
|
|
154 |
unavailableReferentSignal
|
|
155 |
^ Signals at:#unavailableReferentSignal
|
|
156 |
!
|
|
157 |
|
|
158 |
underSpecifiedSignal
|
|
159 |
^ Signals at:#underSpecifiedSignal
|
|
160 |
!
|
|
161 |
|
|
162 |
unpreparedOperationSignal
|
|
163 |
^ Signals at:#unpreparedOperationSignal
|
|
164 |
!
|
|
165 |
|
|
166 |
unsupportedOperationSignal
|
|
167 |
^ Signals at:#unsupportedOperationSignal
|
|
168 |
!
|
|
169 |
|
|
170 |
volumeFullSignal
|
|
171 |
^ Signals at:#volumeFullSignal
|
|
172 |
!
|
|
173 |
|
|
174 |
wrongSubtypeForOperationSignal
|
|
175 |
^ Signals at:#wrongSubtypeForOperationSignal
|
6294
|
176 |
! !
|
|
177 |
|
6270
|
178 |
!OSErrorHolder class methodsFor:'accessing'!
|
|
179 |
|
|
180 |
errorSignal
|
|
181 |
^ OperatingSystem errorSignal
|
|
182 |
|
|
183 |
"Created: 25.1.1997 / 18:07:55 / cg"
|
|
184 |
! !
|
|
185 |
|
6271
|
186 |
!OSErrorHolder class methodsFor:'class initialization'!
|
|
187 |
|
|
188 |
initialize
|
|
189 |
"init signals etc."
|
|
190 |
|
|
191 |
|s|
|
|
192 |
|
|
193 |
OSErrorSignal isNil ifTrue:[
|
6297
|
194 |
OSErrorSignal := OsError.
|
6271
|
195 |
OSErrorSignal notifierString:'OperatingSystem error'.
|
|
196 |
|
6297
|
197 |
Signals := Dictionary new:28.
|
6271
|
198 |
|
6297
|
199 |
OsNoResourcesError notifierString:'Not enough resources'.
|
|
200 |
Signals at:#noResourcesSignal put:OsNoResourcesError.
|
|
201 |
|
|
202 |
OsIllegalOperation notifierString:'Illegal Operation'.
|
|
203 |
Signals at:#illegalOperationSignal put:OsIllegalOperation.
|
|
204 |
|
|
205 |
OsInvalidArgumentsError notifierString:'Invalid Arguments'.
|
|
206 |
Signals at:#invalidArgumentsSignal put:OsInvalidArgumentsError.
|
|
207 |
|
|
208 |
OsInaccessibleError notifierString:'Referent inaccessible'.
|
|
209 |
Signals at:#inaccessibleSignal put:OsInaccessibleError.
|
|
210 |
|
|
211 |
OsTransferFaultError notifierString:'Transfer fault'.
|
|
212 |
Signals at:#transferFaultSignal put:OsTransferFaultError.
|
|
213 |
|
|
214 |
OsNeedRetryError notifierString:'Retry Operation'.
|
|
215 |
Signals at:#needRetrySignal put:OsNeedRetryError.
|
6271
|
216 |
|
6274
|
217 |
false ifTrue:[
|
6271
|
218 |
"/ Information signals
|
|
219 |
|
|
220 |
s := self setupSignal:#informationSignal parent:OSErrorSignal
|
|
221 |
notifier:'Information'.
|
|
222 |
self setupSignal:#operationStartedSignal parent:s
|
|
223 |
notifier:'Operation started'.
|
6297
|
224 |
].
|
6271
|
225 |
"/ Retry signals
|
|
226 |
|
6297
|
227 |
self setupSignal:#notReadySignal parent:OsNeedRetryError
|
6271
|
228 |
notifier:' -- referent not ready'.
|
6297
|
229 |
self setupSignal:#transientErrorSignal parent:OsNeedRetryError
|
6271
|
230 |
notifier:' -- transient error'.
|
6297
|
231 |
self setupSignal:#allocRetrySignal parent:OsNeedRetryError
|
6271
|
232 |
notifier:' -- allocation failure'.
|
|
233 |
|
|
234 |
"/ Resource signals
|
|
235 |
|
6297
|
236 |
self setupSignal:#noMemorySignal parent:OsNoResourcesError
|
6271
|
237 |
notifier:' -- memory'.
|
|
238 |
|
|
239 |
"/ Transfer faults
|
|
240 |
|
6297
|
241 |
self setupSignal:#noDataSignal parent:OsTransferFaultError
|
6271
|
242 |
notifier:'Data unavailable/EOF reached'.
|
6297
|
243 |
self setupSignal:#peerFaultSignal parent:OsTransferFaultError
|
6271
|
244 |
notifier:'Communication with peer failed'.
|
6297
|
245 |
self setupSignal:#volumeFullSignal parent:OsTransferFaultError
|
6271
|
246 |
notifier:'Volume full'.
|
|
247 |
|
|
248 |
"/ Inaccesible faults
|
|
249 |
|
6297
|
250 |
self setupSignal:#nonexistentSignal parent:OsInaccessibleError
|
6271
|
251 |
notifier:'File does not exist'.
|
6297
|
252 |
self setupSignal:#unavailableReferentSignal parent:OsInaccessibleError
|
6271
|
253 |
notifier:' currently'.
|
6297
|
254 |
self setupSignal:#noPermissionsSignal parent:OsInaccessibleError
|
6271
|
255 |
notifier:'Permission denied'.
|
6297
|
256 |
self setupSignal:#existingReferentSignal parent:OsInaccessibleError
|
6271
|
257 |
notifier:' -- already exists or currently in use'.
|
6297
|
258 |
self setupSignal:#inappropriateReferentSignal parent:OsInaccessibleError
|
6271
|
259 |
notifier:' -- operation inappropriate'.
|
|
260 |
|
|
261 |
"/ Illegal operations
|
|
262 |
|
6297
|
263 |
self setupSignal:#inappropriateOperationSignal parent:OsIllegalOperation
|
6271
|
264 |
notifier:'Inappropriate operation'.
|
6297
|
265 |
self setupSignal:#wrongSubtypeForOperationSignal parent:OsIllegalOperation
|
6271
|
266 |
notifier:' -- wrong subtype'.
|
6297
|
267 |
self setupSignal:#unsupportedOperationSignal parent:OsIllegalOperation
|
6271
|
268 |
notifier:' -- on this platform'.
|
6297
|
269 |
self setupSignal:#unpreparedOperationSignal parent:OsIllegalOperation
|
6271
|
270 |
notifier:' -- wrong sequence'.
|
|
271 |
|
|
272 |
"/ Illegal arguments
|
|
273 |
|
6297
|
274 |
self setupSignal:#badArgumentsSignal parent:OsInvalidArgumentsError
|
6271
|
275 |
notifier:' -- wrong class'.
|
6297
|
276 |
self setupSignal:#badAccessorSignal parent:OsInvalidArgumentsError
|
6271
|
277 |
notifier:' -- accessor invalid'.
|
6297
|
278 |
self setupSignal:#rangeErrorSignal parent:OsInvalidArgumentsError
|
6271
|
279 |
notifier:' -- out of range'.
|
6297
|
280 |
self setupSignal:#underSpecifiedSignal parent:OsInvalidArgumentsError
|
6271
|
281 |
notifier:' -- operation not fully specified'.
|
|
282 |
].
|
|
283 |
|
|
284 |
"
|
|
285 |
OSErrorSignal := nil.
|
|
286 |
self initialize
|
|
287 |
"
|
6297
|
288 |
!
|
|
289 |
|
|
290 |
setupSignal:aSymbol parent:parentSignal notifier:aString
|
|
291 |
"setup a signal, which can be retrieved by sending aSymbol to self.
|
|
292 |
Return the new signal"
|
|
293 |
|
|
294 |
|s|
|
|
295 |
|
|
296 |
Signals at:aSymbol
|
|
297 |
put:(s := parentSignal newSignal
|
|
298 |
notifierString:aString;
|
|
299 |
nameClass:self message:aSymbol).
|
|
300 |
^ s
|
6271
|
301 |
! !
|
|
302 |
|
6270
|
303 |
!OSErrorHolder methodsFor:'accessing'!
|
|
304 |
|
6280
|
305 |
errorSymbol:sym errorCategory:typ
|
6270
|
306 |
errorSymbol := sym.
|
|
307 |
errorCategory := typ.
|
|
308 |
! !
|
|
309 |
|
6294
|
310 |
!OSErrorHolder methodsFor:'error reporting'!
|
|
311 |
|
|
312 |
reportError
|
|
313 |
"Report an error."
|
|
314 |
"Delegate to the receiver's error reporter."
|
|
315 |
|
|
316 |
(self class perform:errorCategory) raiseWith:self.
|
|
317 |
self halt.
|
|
318 |
"/ ^ self errorReporter reportOn:self
|
|
319 |
! !
|
|
320 |
|
6271
|
321 |
!OSErrorHolder methodsFor:'others'!
|
|
322 |
|
6274
|
323 |
errorString
|
6280
|
324 |
^ OperatingSystem errorStringForSymbol:errorSymbol
|
6271
|
325 |
!
|
6270
|
326 |
|
6274
|
327 |
errorSymbol
|
|
328 |
^ errorSymbol
|
6270
|
329 |
! !
|
6271
|
330 |
|
|
331 |
OSErrorHolder initialize!
|