author | Claus Gittinger <cg@exept.de> |
Fri, 05 Feb 2010 13:59:41 +0100 | |
changeset 12701 | 9ceabe94c8e1 |
parent 12155 | bd7ed01c3a94 |
child 12954 | 74fbaa673b39 |
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 |
122 |
^ Signals at:#noAccociationSignal |
|
123 |
! |
|
124 |
||
9164 | 125 |
noAggregationSignal |
126 |
^ Signals at:#noAggregationSignal |
|
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 |
|
214 |
^ OperatingSystem errorSignal |
|
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 |
||
224 |
|s| |
|
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 |
|
6274 | 252 |
false ifTrue:[ |
6271 | 253 |
"/ Information signals |
254 |
||
255 |
s := self setupSignal:#informationSignal parent:OSErrorSignal |
|
256 |
notifier:'Information'. |
|
257 |
self setupSignal:#operationStartedSignal parent:s |
|
258 |
notifier:'Operation started'. |
|
6297 | 259 |
]. |
6271 | 260 |
"/ Retry signals |
261 |
||
6297 | 262 |
self setupSignal:#notReadySignal parent:OsNeedRetryError |
6271 | 263 |
notifier:' -- referent not ready'. |
6297 | 264 |
self setupSignal:#transientErrorSignal parent:OsNeedRetryError |
6271 | 265 |
notifier:' -- transient error'. |
6297 | 266 |
self setupSignal:#allocRetrySignal parent:OsNeedRetryError |
6271 | 267 |
notifier:' -- allocation failure'. |
268 |
||
269 |
"/ Resource signals |
|
270 |
||
6297 | 271 |
self setupSignal:#noMemorySignal parent:OsNoResourcesError |
6271 | 272 |
notifier:' -- memory'. |
273 |
||
274 |
"/ Transfer faults |
|
275 |
||
6297 | 276 |
self setupSignal:#noDataSignal parent:OsTransferFaultError |
6271 | 277 |
notifier:'Data unavailable/EOF reached'. |
6297 | 278 |
self setupSignal:#peerFaultSignal parent:OsTransferFaultError |
6271 | 279 |
notifier:'Communication with peer failed'. |
6297 | 280 |
self setupSignal:#volumeFullSignal parent:OsTransferFaultError |
6271 | 281 |
notifier:'Volume full'. |
282 |
||
283 |
"/ Inaccesible faults |
|
284 |
||
6297 | 285 |
self setupSignal:#nonexistentSignal parent:OsInaccessibleError |
6271 | 286 |
notifier:'File does not exist'. |
6297 | 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'. |
|
321 |
self setupSignal:#noInterfaceSignal parent:OsIllegalOperation |
|
322 |
notifier:'No such interface'. |
|
323 |
self setupSignal:#classNotRegisteredSignal parent:OsIllegalOperation |
|
324 |
notifier:'Class not registered'. |
|
325 |
self setupSignal:#noAggregationSignal parent:OsIllegalOperation |
|
326 |
notifier:'No Aggregation'. |
|
327 |
self setupSignal:#unknownNameSignal parent:OsIllegalOperation |
|
328 |
notifier:'Unknown member name'. |
|
9179 | 329 |
self setupSignal:#noVerbsSignal parent:OsIllegalOperation |
330 |
notifier:'No verbs for OLE object'. |
|
11031 | 331 |
|
332 |
"/ Shell errors |
|
333 |
self setupSignal:#noAccociationSignal parent:OsIllegalOperation |
|
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 |
||
6280 | 358 |
errorSymbol:sym errorCategory:typ |
6270 | 359 |
errorSymbol := sym. |
360 |
errorCategory := typ. |
|
10388 | 361 |
! |
362 |
||
363 |
parameter |
|
364 |
^ parameter |
|
365 |
! |
|
366 |
||
367 |
parameter:something |
|
368 |
parameter := something. |
|
6270 | 369 |
! ! |
370 |
||
6294 | 371 |
!OSErrorHolder methodsFor:'error reporting'! |
372 |
||
373 |
reportError |
|
374 |
"Report an error." |
|
375 |
"Delegate to the receiver's error reporter." |
|
376 |
||
9179 | 377 |
|signal| |
378 |
||
379 |
signal := self class signalNamed:errorCategory. |
|
12155 | 380 |
signal |
381 |
raiseWith:self |
|
382 |
errorString:(parameter isNil ifTrue:[''] ifFalse:[' - ', parameter printString]) |
|
383 |
in:(thisContext sender). |
|
9179 | 384 |
|
6294 | 385 |
"/ ^ self errorReporter reportOn:self |
386 |
! ! |
|
387 |
||
6271 | 388 |
!OSErrorHolder methodsFor:'others'! |
389 |
||
10388 | 390 |
errorString |
391 |
|s| |
|
392 |
||
393 |
s := OperatingSystem errorStringForSymbol:errorSymbol. |
|
394 |
parameter notNil ifTrue:[ |
|
395 |
^ s,': ',parameter printString. |
|
396 |
]. |
|
397 |
^ s |
|
398 |
||
399 |
"Modified: / 12-02-2007 / 12:29:07 / cg" |
|
6271 | 400 |
! |
6270 | 401 |
|
6274 | 402 |
errorSymbol |
403 |
^ errorSymbol |
|
6270 | 404 |
! ! |
6271 | 405 |
|
7593 | 406 |
!OSErrorHolder class methodsFor:'documentation'! |
407 |
||
408 |
version |
|
12155 | 409 |
^ '$Header: /cvs/stx/stx/libbasic/OSErrorHolder.st,v 1.17 2009-10-06 08:31:33 cg Exp $' |
410 |
! |
|
411 |
||
412 |
version_CVS |
|
413 |
^ '$Header: /cvs/stx/stx/libbasic/OSErrorHolder.st,v 1.17 2009-10-06 08:31:33 cg Exp $' |
|
7593 | 414 |
! ! |
415 |
||
6271 | 416 |
OSErrorHolder initialize! |