author | Claus Gittinger <cg@exept.de> |
Tue, 18 Feb 2014 14:41:40 +0100 | |
changeset 16071 | 52286691aad5 |
parent 15497 | e68180b4bb68 |
child 17464 | 1e64af8a4514 |
child 18075 | bd252c0beac9 |
permissions | -rw-r--r-- |
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 |
" |
|
6271 | 12 |
"{ Package: 'stx:libbasic' }" |
6270 | 13 |
|
14 |
Object subclass:#OSErrorHolder |
|
10388 | 15 |
instanceVariableNames:'errorSymbol errorCategory parameter' |
6271 | 16 |
classVariableNames:'Signals OSErrorSignal' |
6270 | 17 |
poolDictionaries:'' |
6271 | 18 |
category:'OS-Support' |
6270 | 19 |
! |
20 |
||
21 |
!OSErrorHolder class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
||
36 |
||
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
6271 | 41 |
This class represents low level operating system errors. |
42 |
We do not use error numbers, because there may be different errnos |
|
43 |
for the same error on different systems. |
|
6270 | 44 |
|
6271 | 45 |
[instance variables:] |
46 |
errorSymbol symbol associated with this error |
|
47 |
errorCategory symbol defining the error category. |
|
48 |
This is in fact a symbol that returns a |
|
49 |
Signal when sent to myself. |
|
6270 | 50 |
|
6271 | 51 |
While the errorSymbol may be different on different platforms, |
52 |
the errorCategories (which refer to the Signals that will be raised) |
|
53 |
are identical. |
|
54 |
You can get an OS independent error message for an error by sending |
|
55 |
#errorCategoryString. |
|
56 |
||
57 |
[author:] |
|
58 |
Stefan Vogel |
|
59 |
||
60 |
[see also:] |
|
61 |
OperatingSystem |
|
6270 | 62 |
" |
63 |
! ! |
|
64 |
||
6294 | 65 |
!OSErrorHolder class methodsFor:'Signal constants'! |
66 |
||
6297 | 67 |
allocRetrySignal |
68 |
^ Signals at:#allocRetrySignal |
|
69 |
! |
|
70 |
||
71 |
badAccessorSignal |
|
72 |
^ Signals at:#badAccessorSignal |
|
73 |
! |
|
74 |
||
75 |
badArgumentsSignal |
|
76 |
^ Signals at:#badArgumentsSignal |
|
77 |
! |
|
78 |
||
9164 | 79 |
classNotRegisteredSignal |
80 |
^ Signals at:#classNotRegisteredSignal |
|
81 |
! |
|
82 |
||
83 |
coNotInitializedSignal |
|
84 |
^ Signals at:#coNotInitializedSignal |
|
85 |
! |
|
86 |
||
10751
c3fdb104adba
dont forget the defaultOsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
10388
diff
changeset
|
87 |
defaultOsErrorSignal |
c3fdb104adba
dont forget the defaultOsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
10388
diff
changeset
|
88 |
^ Signals at:#defaultOsErrorSignal |
c3fdb104adba
dont forget the defaultOsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
10388
diff
changeset
|
89 |
! |
c3fdb104adba
dont forget the defaultOsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
10388
diff
changeset
|
90 |
|
6297 | 91 |
existingReferentSignal |
92 |
^ Signals at:#existingReferentSignal |
|
93 |
! |
|
94 |
||
95 |
illegalOperationSignal |
|
96 |
^ Signals at:#illegalOperationSignal |
|
97 |
! |
|
98 |
||
99 |
inaccessibleSignal |
|
100 |
^ Signals at:#inaccessibleSignal |
|
101 |
! |
|
102 |
||
103 |
inappropriateOperationSignal |
|
104 |
^ Signals at:#inappropriateOperationSignal |
|
105 |
! |
|
106 |
||
107 |
inappropriateReferentSignal |
|
108 |
^ Signals at:#inappropriateReferentSignal |
|
109 |
! |
|
110 |
||
6294 | 111 |
invalidArgumentsSignal |
112 |
"return the signal for invalid arguments (e.g. right class, wrong value)." |
|
113 |
||
114 |
^ OsInvalidArgumentsError |
|
6297 | 115 |
! |
116 |
||
117 |
needRetrySignal |
|
118 |
^ Signals at:#needRetrySignal |
|
119 |
! |
|
120 |
||
9164 | 121 |
noAggregationSignal |
122 |
^ Signals at:#noAggregationSignal |
|
123 |
! |
|
124 |
||
12954 | 125 |
noAssociationSignal |
126 |
^ Signals at:#noAssociationSignal |
|
127 |
! |
|
128 |
||
6297 | 129 |
noDataSignal |
130 |
^ Signals at:#noDataSignal |
|
131 |
! |
|
132 |
||
9164 | 133 |
noInterfaceSignal |
134 |
^ Signals at:#noInterfaceSignal |
|
135 |
! |
|
136 |
||
6297 | 137 |
noMemorySignal |
138 |
^ Signals at:#noMemorySignal |
|
139 |
! |
|
140 |
||
141 |
noPermissionsSignal |
|
142 |
^ Signals at:#noPermissionsSignal |
|
143 |
! |
|
144 |
||
145 |
noResourcesSignal |
|
146 |
^ Signals at:#noResourcesSignal |
|
147 |
! |
|
148 |
||
9179 | 149 |
noVerbsSignal |
150 |
^ Signals at:#noVerbsSignal |
|
151 |
! |
|
152 |
||
6297 | 153 |
nonexistentSignal |
154 |
"return the signal for non existing referents (i.e. device, file etc.)." |
|
155 |
||
156 |
^ Signals at:#nonexistentSignal |
|
157 |
! |
|
158 |
||
159 |
notReadySignal |
|
160 |
^ Signals at:#notReadySignal |
|
161 |
! |
|
162 |
||
163 |
peerFaultSignal |
|
164 |
^ Signals at:#peerFaultSignal |
|
165 |
! |
|
166 |
||
167 |
rangeErrorSignal |
|
168 |
^ Signals at:#rangeErrorSignal |
|
169 |
! |
|
170 |
||
9179 | 171 |
signalNamed:signalName |
172 |
^ Signals at:signalName |
|
173 |
! |
|
174 |
||
6297 | 175 |
transferFaultSignal |
176 |
^ Signals at:#transferFaultSignal |
|
177 |
! |
|
178 |
||
179 |
transientErrorSignal |
|
180 |
^ Signals at:#transientErrorSignal |
|
181 |
! |
|
182 |
||
183 |
unavailableReferentSignal |
|
184 |
^ Signals at:#unavailableReferentSignal |
|
185 |
! |
|
186 |
||
187 |
underSpecifiedSignal |
|
188 |
^ Signals at:#underSpecifiedSignal |
|
189 |
! |
|
190 |
||
9164 | 191 |
unknownNameSignal |
192 |
^ Signals at:#unknownNameSignal |
|
193 |
! |
|
194 |
||
6297 | 195 |
unpreparedOperationSignal |
196 |
^ Signals at:#unpreparedOperationSignal |
|
197 |
! |
|
198 |
||
199 |
unsupportedOperationSignal |
|
200 |
^ Signals at:#unsupportedOperationSignal |
|
201 |
! |
|
202 |
||
203 |
volumeFullSignal |
|
204 |
^ Signals at:#volumeFullSignal |
|
205 |
! |
|
206 |
||
207 |
wrongSubtypeForOperationSignal |
|
208 |
^ Signals at:#wrongSubtypeForOperationSignal |
|
6294 | 209 |
! ! |
210 |
||
6270 | 211 |
!OSErrorHolder class methodsFor:'accessing'! |
212 |
||
213 |
errorSignal |
|
15191 | 214 |
^ OsError |
6270 | 215 |
|
216 |
"Created: 25.1.1997 / 18:07:55 / cg" |
|
217 |
! ! |
|
218 |
||
6271 | 219 |
!OSErrorHolder class methodsFor:'class initialization'! |
220 |
||
221 |
initialize |
|
222 |
"init signals etc." |
|
223 |
||
12957 | 224 |
|unavailableReferentSignal| |
6271 | 225 |
|
226 |
OSErrorSignal isNil ifTrue:[ |
|
6297 | 227 |
OSErrorSignal := OsError. |
6271 | 228 |
OSErrorSignal notifierString:'OperatingSystem error'. |
229 |
||
10751
c3fdb104adba
dont forget the defaultOsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
10388
diff
changeset
|
230 |
Signals := Dictionary new:40. |
6271 | 231 |
|
6297 | 232 |
OsNoResourcesError notifierString:'Not enough resources'. |
233 |
Signals at:#noResourcesSignal put:OsNoResourcesError. |
|
234 |
||
235 |
OsIllegalOperation notifierString:'Illegal Operation'. |
|
236 |
Signals at:#illegalOperationSignal put:OsIllegalOperation. |
|
237 |
||
238 |
OsInvalidArgumentsError notifierString:'Invalid Arguments'. |
|
239 |
Signals at:#invalidArgumentsSignal put:OsInvalidArgumentsError. |
|
240 |
||
241 |
OsInaccessibleError notifierString:'Referent inaccessible'. |
|
242 |
Signals at:#inaccessibleSignal put:OsInaccessibleError. |
|
243 |
||
244 |
OsTransferFaultError notifierString:'Transfer fault'. |
|
245 |
Signals at:#transferFaultSignal put:OsTransferFaultError. |
|
246 |
||
247 |
OsNeedRetryError notifierString:'Retry Operation'. |
|
248 |
Signals at:#needRetrySignal put:OsNeedRetryError. |
|
6271 | 249 |
|
10751
c3fdb104adba
dont forget the defaultOsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
10388
diff
changeset
|
250 |
Signals at:#defaultOsErrorSignal put:OSErrorSignal. |
c3fdb104adba
dont forget the defaultOsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
10388
diff
changeset
|
251 |
|
6271 | 252 |
"/ Information signals |
253 |
||
12957 | 254 |
"/ s := self setupSignal:#informationSignal parent:OSErrorSignal |
255 |
"/ notifier:'Information'. |
|
256 |
"/ self setupSignal:#operationStartedSignal parent:s |
|
257 |
"/ notifier:'Operation started'. |
|
258 |
||
6271 | 259 |
"/ Retry signals |
260 |
||
6297 | 261 |
self setupSignal:#notReadySignal parent:OsNeedRetryError |
6271 | 262 |
notifier:' -- referent not ready'. |
6297 | 263 |
self setupSignal:#transientErrorSignal parent:OsNeedRetryError |
6271 | 264 |
notifier:' -- transient error'. |
6297 | 265 |
self setupSignal:#allocRetrySignal parent:OsNeedRetryError |
6271 | 266 |
notifier:' -- allocation failure'. |
267 |
||
268 |
"/ Resource signals |
|
269 |
||
6297 | 270 |
self setupSignal:#noMemorySignal parent:OsNoResourcesError |
6271 | 271 |
notifier:' -- memory'. |
272 |
||
273 |
"/ Transfer faults |
|
274 |
||
6297 | 275 |
self setupSignal:#noDataSignal parent:OsTransferFaultError |
6271 | 276 |
notifier:'Data unavailable/EOF reached'. |
6297 | 277 |
self setupSignal:#peerFaultSignal parent:OsTransferFaultError |
6271 | 278 |
notifier:'Communication with peer failed'. |
6297 | 279 |
self setupSignal:#volumeFullSignal parent:OsTransferFaultError |
6271 | 280 |
notifier:'Volume full'. |
281 |
||
282 |
"/ Inaccesible faults |
|
283 |
||
6297 | 284 |
self setupSignal:#nonexistentSignal parent:OsInaccessibleError |
6271 | 285 |
notifier:'File does not exist'. |
12957 | 286 |
unavailableReferentSignal := |
287 |
self setupSignal:#unavailableReferentSignal parent:OsInaccessibleError |
|
6271 | 288 |
notifier:' currently'. |
6297 | 289 |
self setupSignal:#noPermissionsSignal parent:OsInaccessibleError |
6271 | 290 |
notifier:'Permission denied'. |
6297 | 291 |
self setupSignal:#existingReferentSignal parent:OsInaccessibleError |
6271 | 292 |
notifier:' -- already exists or currently in use'. |
6297 | 293 |
self setupSignal:#inappropriateReferentSignal parent:OsInaccessibleError |
6271 | 294 |
notifier:' -- operation inappropriate'. |
295 |
||
296 |
"/ Illegal operations |
|
297 |
||
6297 | 298 |
self setupSignal:#inappropriateOperationSignal parent:OsIllegalOperation |
6271 | 299 |
notifier:'Inappropriate operation'. |
6297 | 300 |
self setupSignal:#wrongSubtypeForOperationSignal parent:OsIllegalOperation |
6271 | 301 |
notifier:' -- wrong subtype'. |
6297 | 302 |
self setupSignal:#unsupportedOperationSignal parent:OsIllegalOperation |
6271 | 303 |
notifier:' -- on this platform'. |
6297 | 304 |
self setupSignal:#unpreparedOperationSignal parent:OsIllegalOperation |
6271 | 305 |
notifier:' -- wrong sequence'. |
306 |
||
307 |
"/ Illegal arguments |
|
308 |
||
6297 | 309 |
self setupSignal:#badArgumentsSignal parent:OsInvalidArgumentsError |
6271 | 310 |
notifier:' -- wrong class'. |
6297 | 311 |
self setupSignal:#badAccessorSignal parent:OsInvalidArgumentsError |
6271 | 312 |
notifier:' -- accessor invalid'. |
6297 | 313 |
self setupSignal:#rangeErrorSignal parent:OsInvalidArgumentsError |
6271 | 314 |
notifier:' -- out of range'. |
6297 | 315 |
self setupSignal:#underSpecifiedSignal parent:OsInvalidArgumentsError |
6271 | 316 |
notifier:' -- operation not fully specified'. |
9164 | 317 |
|
318 |
"/ COM errors |
|
319 |
self setupSignal:#coNotInitializedSignal parent:OsIllegalOperation |
|
320 |
notifier:'COM not initialized'. |
|
12957 | 321 |
self setupSignal:#noInterfaceSignal parent:unavailableReferentSignal |
9164 | 322 |
notifier:'No such interface'. |
12957 | 323 |
self setupSignal:#classNotRegisteredSignal parent:unavailableReferentSignal |
9164 | 324 |
notifier:'Class not registered'. |
325 |
self setupSignal:#noAggregationSignal parent:OsIllegalOperation |
|
326 |
notifier:'No Aggregation'. |
|
12957 | 327 |
self setupSignal:#unknownNameSignal parent:unavailableReferentSignal |
9164 | 328 |
notifier:'Unknown member name'. |
9179 | 329 |
self setupSignal:#noVerbsSignal parent:OsIllegalOperation |
330 |
notifier:'No verbs for OLE object'. |
|
11031 | 331 |
|
332 |
"/ Shell errors |
|
12957 | 333 |
self setupSignal:#noAssociationSignal parent:unavailableReferentSignal |
11033 | 334 |
notifier:'No association for file extension'. |
6271 | 335 |
]. |
336 |
||
337 |
" |
|
338 |
OSErrorSignal := nil. |
|
339 |
self initialize |
|
340 |
" |
|
6297 | 341 |
! |
342 |
||
343 |
setupSignal:aSymbol parent:parentSignal notifier:aString |
|
344 |
"setup a signal, which can be retrieved by sending aSymbol to self. |
|
345 |
Return the new signal" |
|
346 |
||
347 |
|s| |
|
348 |
||
349 |
Signals at:aSymbol |
|
350 |
put:(s := parentSignal newSignal |
|
351 |
notifierString:aString; |
|
352 |
nameClass:self message:aSymbol). |
|
353 |
^ s |
|
6271 | 354 |
! ! |
355 |
||
6270 | 356 |
!OSErrorHolder methodsFor:'accessing'! |
357 |
||
15463 | 358 |
errorCategory |
359 |
^ errorCategory |
|
360 |
! |
|
361 |
||
362 |
errorSymbol |
|
363 |
^ errorSymbol |
|
364 |
! |
|
365 |
||
6280 | 366 |
errorSymbol:sym errorCategory:typ |
6270 | 367 |
errorSymbol := sym. |
368 |
errorCategory := typ. |
|
10388 | 369 |
! |
370 |
||
371 |
parameter |
|
372 |
^ parameter |
|
373 |
! |
|
374 |
||
375 |
parameter:something |
|
376 |
parameter := something. |
|
6270 | 377 |
! ! |
378 |
||
6294 | 379 |
!OSErrorHolder methodsFor:'error reporting'! |
380 |
||
381 |
reportError |
|
382 |
"Report an error." |
|
383 |
"Delegate to the receiver's error reporter." |
|
384 |
||
9179 | 385 |
|signal| |
386 |
||
387 |
signal := self class signalNamed:errorCategory. |
|
12155 | 388 |
signal |
389 |
raiseWith:self |
|
12957 | 390 |
errorString:(parameter isNil ifTrue:[nil] ifFalse:[' - ', parameter printString]) |
12155 | 391 |
in:(thisContext sender). |
9179 | 392 |
|
6294 | 393 |
"/ ^ self errorReporter reportOn:self |
394 |
! ! |
|
395 |
||
6271 | 396 |
!OSErrorHolder methodsFor:'others'! |
397 |
||
10388 | 398 |
errorString |
399 |
|s| |
|
400 |
||
401 |
s := OperatingSystem errorStringForSymbol:errorSymbol. |
|
402 |
parameter notNil ifTrue:[ |
|
403 |
^ s,': ',parameter printString. |
|
404 |
]. |
|
405 |
^ s |
|
406 |
||
407 |
"Modified: / 12-02-2007 / 12:29:07 / cg" |
|
15463 | 408 |
! ! |
409 |
||
410 |
!OSErrorHolder methodsFor:'printing'! |
|
6270 | 411 |
|
15463 | 412 |
printOn:aStream |
413 |
aStream |
|
414 |
nextPutAll:self className; |
|
415 |
nextPut:$(; |
|
416 |
nextPutAll:errorSymbol; |
|
417 |
nextPutAll:', '; |
|
418 |
nextPutAll:errorCategory; |
|
419 |
nextPut:$). |
|
6270 | 420 |
! ! |
6271 | 421 |
|
7593 | 422 |
!OSErrorHolder class methodsFor:'documentation'! |
423 |
||
424 |
version |
|
15497 | 425 |
^ '$Header: /cvs/stx/stx/libbasic/OSErrorHolder.st,v 1.22 2013-07-09 11:56:56 stefan Exp $' |
12155 | 426 |
! |
427 |
||
428 |
version_CVS |
|
15497 | 429 |
^ '$Header: /cvs/stx/stx/libbasic/OSErrorHolder.st,v 1.22 2013-07-09 11:56:56 stefan Exp $' |
7593 | 430 |
! ! |
431 |
||
15191 | 432 |
|
6271 | 433 |
OSErrorHolder initialize! |