author | Claus Gittinger <cg@exept.de> |
Thu, 07 Jun 2012 11:08:32 +0200 | |
changeset 14158 | 8565a6b7f00a |
parent 12957 | c7a000017d17 |
child 15191 | 3b22de53549b |
child 18011 | deb0c3355881 |
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 |
||
11031 | 121 |
noAccociationSignal |
12954 | 122 |
<resource: #obsolete> |
123 |
self obsoleteMethodWarning. |
|
124 |
^ self noAssociationSignal |
|
11031 | 125 |
! |
126 |
||
9164 | 127 |
noAggregationSignal |
128 |
^ Signals at:#noAggregationSignal |
|
129 |
! |
|
130 |
||
12954 | 131 |
noAssociationSignal |
132 |
^ Signals at:#noAssociationSignal |
|
133 |
! |
|
134 |
||
6297 | 135 |
noDataSignal |
136 |
^ Signals at:#noDataSignal |
|
137 |
! |
|
138 |
||
9164 | 139 |
noInterfaceSignal |
140 |
^ Signals at:#noInterfaceSignal |
|
141 |
! |
|
142 |
||
6297 | 143 |
noMemorySignal |
144 |
^ Signals at:#noMemorySignal |
|
145 |
! |
|
146 |
||
147 |
noPermissionsSignal |
|
148 |
^ Signals at:#noPermissionsSignal |
|
149 |
! |
|
150 |
||
151 |
noResourcesSignal |
|
152 |
^ Signals at:#noResourcesSignal |
|
153 |
! |
|
154 |
||
9179 | 155 |
noVerbsSignal |
156 |
^ Signals at:#noVerbsSignal |
|
157 |
! |
|
158 |
||
6297 | 159 |
nonexistentSignal |
160 |
"return the signal for non existing referents (i.e. device, file etc.)." |
|
161 |
||
162 |
^ Signals at:#nonexistentSignal |
|
163 |
! |
|
164 |
||
165 |
notReadySignal |
|
166 |
^ Signals at:#notReadySignal |
|
167 |
! |
|
168 |
||
169 |
peerFaultSignal |
|
170 |
^ Signals at:#peerFaultSignal |
|
171 |
! |
|
172 |
||
173 |
rangeErrorSignal |
|
174 |
^ Signals at:#rangeErrorSignal |
|
175 |
! |
|
176 |
||
9179 | 177 |
signalNamed:signalName |
178 |
^ Signals at:signalName |
|
179 |
! |
|
180 |
||
6297 | 181 |
transferFaultSignal |
182 |
^ Signals at:#transferFaultSignal |
|
183 |
! |
|
184 |
||
185 |
transientErrorSignal |
|
186 |
^ Signals at:#transientErrorSignal |
|
187 |
! |
|
188 |
||
189 |
unavailableReferentSignal |
|
190 |
^ Signals at:#unavailableReferentSignal |
|
191 |
! |
|
192 |
||
193 |
underSpecifiedSignal |
|
194 |
^ Signals at:#underSpecifiedSignal |
|
195 |
! |
|
196 |
||
9164 | 197 |
unknownNameSignal |
198 |
^ Signals at:#unknownNameSignal |
|
199 |
! |
|
200 |
||
6297 | 201 |
unpreparedOperationSignal |
202 |
^ Signals at:#unpreparedOperationSignal |
|
203 |
! |
|
204 |
||
205 |
unsupportedOperationSignal |
|
206 |
^ Signals at:#unsupportedOperationSignal |
|
207 |
! |
|
208 |
||
209 |
volumeFullSignal |
|
210 |
^ Signals at:#volumeFullSignal |
|
211 |
! |
|
212 |
||
213 |
wrongSubtypeForOperationSignal |
|
214 |
^ Signals at:#wrongSubtypeForOperationSignal |
|
6294 | 215 |
! ! |
216 |
||
6270 | 217 |
!OSErrorHolder class methodsFor:'accessing'! |
218 |
||
219 |
errorSignal |
|
220 |
^ OperatingSystem errorSignal |
|
221 |
||
222 |
"Created: 25.1.1997 / 18:07:55 / cg" |
|
223 |
! ! |
|
224 |
||
6271 | 225 |
!OSErrorHolder class methodsFor:'class initialization'! |
226 |
||
227 |
initialize |
|
228 |
"init signals etc." |
|
229 |
||
12957 | 230 |
|unavailableReferentSignal| |
6271 | 231 |
|
232 |
OSErrorSignal isNil ifTrue:[ |
|
6297 | 233 |
OSErrorSignal := OsError. |
6271 | 234 |
OSErrorSignal notifierString:'OperatingSystem error'. |
235 |
||
10751
c3fdb104adba
dont forget the defaultOsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
10388
diff
changeset
|
236 |
Signals := Dictionary new:40. |
6271 | 237 |
|
6297 | 238 |
OsNoResourcesError notifierString:'Not enough resources'. |
239 |
Signals at:#noResourcesSignal put:OsNoResourcesError. |
|
240 |
||
241 |
OsIllegalOperation notifierString:'Illegal Operation'. |
|
242 |
Signals at:#illegalOperationSignal put:OsIllegalOperation. |
|
243 |
||
244 |
OsInvalidArgumentsError notifierString:'Invalid Arguments'. |
|
245 |
Signals at:#invalidArgumentsSignal put:OsInvalidArgumentsError. |
|
246 |
||
247 |
OsInaccessibleError notifierString:'Referent inaccessible'. |
|
248 |
Signals at:#inaccessibleSignal put:OsInaccessibleError. |
|
249 |
||
250 |
OsTransferFaultError notifierString:'Transfer fault'. |
|
251 |
Signals at:#transferFaultSignal put:OsTransferFaultError. |
|
252 |
||
253 |
OsNeedRetryError notifierString:'Retry Operation'. |
|
254 |
Signals at:#needRetrySignal put:OsNeedRetryError. |
|
6271 | 255 |
|
10751
c3fdb104adba
dont forget the defaultOsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
10388
diff
changeset
|
256 |
Signals at:#defaultOsErrorSignal put:OSErrorSignal. |
c3fdb104adba
dont forget the defaultOsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
10388
diff
changeset
|
257 |
|
6271 | 258 |
"/ Information signals |
259 |
||
12957 | 260 |
"/ s := self setupSignal:#informationSignal parent:OSErrorSignal |
261 |
"/ notifier:'Information'. |
|
262 |
"/ self setupSignal:#operationStartedSignal parent:s |
|
263 |
"/ notifier:'Operation started'. |
|
264 |
||
6271 | 265 |
"/ Retry signals |
266 |
||
6297 | 267 |
self setupSignal:#notReadySignal parent:OsNeedRetryError |
6271 | 268 |
notifier:' -- referent not ready'. |
6297 | 269 |
self setupSignal:#transientErrorSignal parent:OsNeedRetryError |
6271 | 270 |
notifier:' -- transient error'. |
6297 | 271 |
self setupSignal:#allocRetrySignal parent:OsNeedRetryError |
6271 | 272 |
notifier:' -- allocation failure'. |
273 |
||
274 |
"/ Resource signals |
|
275 |
||
6297 | 276 |
self setupSignal:#noMemorySignal parent:OsNoResourcesError |
6271 | 277 |
notifier:' -- memory'. |
278 |
||
279 |
"/ Transfer faults |
|
280 |
||
6297 | 281 |
self setupSignal:#noDataSignal parent:OsTransferFaultError |
6271 | 282 |
notifier:'Data unavailable/EOF reached'. |
6297 | 283 |
self setupSignal:#peerFaultSignal parent:OsTransferFaultError |
6271 | 284 |
notifier:'Communication with peer failed'. |
6297 | 285 |
self setupSignal:#volumeFullSignal parent:OsTransferFaultError |
6271 | 286 |
notifier:'Volume full'. |
287 |
||
288 |
"/ Inaccesible faults |
|
289 |
||
6297 | 290 |
self setupSignal:#nonexistentSignal parent:OsInaccessibleError |
6271 | 291 |
notifier:'File does not exist'. |
12957 | 292 |
unavailableReferentSignal := |
293 |
self setupSignal:#unavailableReferentSignal parent:OsInaccessibleError |
|
6271 | 294 |
notifier:' currently'. |
6297 | 295 |
self setupSignal:#noPermissionsSignal parent:OsInaccessibleError |
6271 | 296 |
notifier:'Permission denied'. |
6297 | 297 |
self setupSignal:#existingReferentSignal parent:OsInaccessibleError |
6271 | 298 |
notifier:' -- already exists or currently in use'. |
6297 | 299 |
self setupSignal:#inappropriateReferentSignal parent:OsInaccessibleError |
6271 | 300 |
notifier:' -- operation inappropriate'. |
301 |
||
302 |
"/ Illegal operations |
|
303 |
||
6297 | 304 |
self setupSignal:#inappropriateOperationSignal parent:OsIllegalOperation |
6271 | 305 |
notifier:'Inappropriate operation'. |
6297 | 306 |
self setupSignal:#wrongSubtypeForOperationSignal parent:OsIllegalOperation |
6271 | 307 |
notifier:' -- wrong subtype'. |
6297 | 308 |
self setupSignal:#unsupportedOperationSignal parent:OsIllegalOperation |
6271 | 309 |
notifier:' -- on this platform'. |
6297 | 310 |
self setupSignal:#unpreparedOperationSignal parent:OsIllegalOperation |
6271 | 311 |
notifier:' -- wrong sequence'. |
312 |
||
313 |
"/ Illegal arguments |
|
314 |
||
6297 | 315 |
self setupSignal:#badArgumentsSignal parent:OsInvalidArgumentsError |
6271 | 316 |
notifier:' -- wrong class'. |
6297 | 317 |
self setupSignal:#badAccessorSignal parent:OsInvalidArgumentsError |
6271 | 318 |
notifier:' -- accessor invalid'. |
6297 | 319 |
self setupSignal:#rangeErrorSignal parent:OsInvalidArgumentsError |
6271 | 320 |
notifier:' -- out of range'. |
6297 | 321 |
self setupSignal:#underSpecifiedSignal parent:OsInvalidArgumentsError |
6271 | 322 |
notifier:' -- operation not fully specified'. |
9164 | 323 |
|
324 |
"/ COM errors |
|
325 |
self setupSignal:#coNotInitializedSignal parent:OsIllegalOperation |
|
326 |
notifier:'COM not initialized'. |
|
12957 | 327 |
self setupSignal:#noInterfaceSignal parent:unavailableReferentSignal |
9164 | 328 |
notifier:'No such interface'. |
12957 | 329 |
self setupSignal:#classNotRegisteredSignal parent:unavailableReferentSignal |
9164 | 330 |
notifier:'Class not registered'. |
331 |
self setupSignal:#noAggregationSignal parent:OsIllegalOperation |
|
332 |
notifier:'No Aggregation'. |
|
12957 | 333 |
self setupSignal:#unknownNameSignal parent:unavailableReferentSignal |
9164 | 334 |
notifier:'Unknown member name'. |
9179 | 335 |
self setupSignal:#noVerbsSignal parent:OsIllegalOperation |
336 |
notifier:'No verbs for OLE object'. |
|
11031 | 337 |
|
338 |
"/ Shell errors |
|
12957 | 339 |
self setupSignal:#noAssociationSignal parent:unavailableReferentSignal |
11033 | 340 |
notifier:'No association for file extension'. |
6271 | 341 |
]. |
342 |
||
343 |
" |
|
344 |
OSErrorSignal := nil. |
|
345 |
self initialize |
|
346 |
" |
|
6297 | 347 |
! |
348 |
||
349 |
setupSignal:aSymbol parent:parentSignal notifier:aString |
|
350 |
"setup a signal, which can be retrieved by sending aSymbol to self. |
|
351 |
Return the new signal" |
|
352 |
||
353 |
|s| |
|
354 |
||
355 |
Signals at:aSymbol |
|
356 |
put:(s := parentSignal newSignal |
|
357 |
notifierString:aString; |
|
358 |
nameClass:self message:aSymbol). |
|
359 |
^ s |
|
6271 | 360 |
! ! |
361 |
||
6270 | 362 |
!OSErrorHolder methodsFor:'accessing'! |
363 |
||
6280 | 364 |
errorSymbol:sym errorCategory:typ |
6270 | 365 |
errorSymbol := sym. |
366 |
errorCategory := typ. |
|
10388 | 367 |
! |
368 |
||
369 |
parameter |
|
370 |
^ parameter |
|
371 |
! |
|
372 |
||
373 |
parameter:something |
|
374 |
parameter := something. |
|
6270 | 375 |
! ! |
376 |
||
6294 | 377 |
!OSErrorHolder methodsFor:'error reporting'! |
378 |
||
379 |
reportError |
|
380 |
"Report an error." |
|
381 |
"Delegate to the receiver's error reporter." |
|
382 |
||
9179 | 383 |
|signal| |
384 |
||
385 |
signal := self class signalNamed:errorCategory. |
|
12155 | 386 |
signal |
387 |
raiseWith:self |
|
12957 | 388 |
errorString:(parameter isNil ifTrue:[nil] ifFalse:[' - ', parameter printString]) |
12155 | 389 |
in:(thisContext sender). |
9179 | 390 |
|
6294 | 391 |
"/ ^ self errorReporter reportOn:self |
392 |
! ! |
|
393 |
||
6271 | 394 |
!OSErrorHolder methodsFor:'others'! |
395 |
||
10388 | 396 |
errorString |
397 |
|s| |
|
398 |
||
399 |
s := OperatingSystem errorStringForSymbol:errorSymbol. |
|
400 |
parameter notNil ifTrue:[ |
|
401 |
^ s,': ',parameter printString. |
|
402 |
]. |
|
403 |
^ s |
|
404 |
||
405 |
"Modified: / 12-02-2007 / 12:29:07 / cg" |
|
6271 | 406 |
! |
6270 | 407 |
|
6274 | 408 |
errorSymbol |
409 |
^ errorSymbol |
|
6270 | 410 |
! ! |
6271 | 411 |
|
7593 | 412 |
!OSErrorHolder class methodsFor:'documentation'! |
413 |
||
414 |
version |
|
12957 | 415 |
^ '$Header: /cvs/stx/stx/libbasic/OSErrorHolder.st,v 1.19 2010-07-22 18:11:49 stefan Exp $' |
12155 | 416 |
! |
417 |
||
418 |
version_CVS |
|
12957 | 419 |
^ '$Header: /cvs/stx/stx/libbasic/OSErrorHolder.st,v 1.19 2010-07-22 18:11:49 stefan Exp $' |
7593 | 420 |
! ! |
421 |
||
6271 | 422 |
OSErrorHolder initialize! |