|
1 " |
|
2 COPYRIGHT (c) 1993 by 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 Object subclass:#Exception |
|
14 instanceVariableNames:'signal parameter suspendedContext handlerContext |
|
15 resumeBlock rejectBlock' |
|
16 classVariableNames:'' |
|
17 poolDictionaries:'' |
|
18 category:'Kernel-Exceptions' |
|
19 ! |
|
20 |
|
21 Exception comment:' |
|
22 |
|
23 COPYRIGHT (c) 1993 by Claus Gittinger |
|
24 All Rights Reserved |
|
25 |
|
26 Instances of Exception are passed to a Signal handling block as argument. |
|
27 The handler block may perform various actions by sending corresponding messages |
|
28 to the exception handler. The following actions are possible: |
|
29 |
|
30 reject - dont handle this signal; |
|
31 another handler will be searched for, |
|
32 upper in the calling hierarchy |
|
33 |
|
34 proceed - continue after the Signal>>raise, returning nil as value |
|
35 proceedWith:val - same, but return val from Signal>>raise |
|
36 |
|
37 return - return from the Signal>>handle:do:, returning nil as value |
|
38 return:val - same, but return val from Signal>>handle:do: |
|
39 |
|
40 restart - restart the Signal>>handle:do:, after repairing |
|
41 |
|
42 Via the Exception object, the handler can also query the state of execution, |
|
43 where the Signal was raised. |
|
44 '! |
|
45 |
|
46 !Exception methodsFor:'accessing'! |
|
47 |
|
48 signal |
|
49 "return the signal, that caused the exception" |
|
50 |
|
51 ^ signal |
|
52 ! |
|
53 |
|
54 parameter:aParameter |
|
55 parameter := aParameter |
|
56 ! |
|
57 |
|
58 parameter |
|
59 ^ parameter |
|
60 ! |
|
61 |
|
62 suspendedContext |
|
63 ! ! |
|
64 |
|
65 !Exception methodsFor:'setup'! |
|
66 |
|
67 signal:aSignal |
|
68 "this is meant to be sent by Signal only" |
|
69 |
|
70 signal := aSignal |
|
71 ! |
|
72 |
|
73 handlerContext:aContext |
|
74 "this is meant to be sent by Signal only" |
|
75 |
|
76 handlerContext := aContext |
|
77 ! |
|
78 |
|
79 rejectBlock:aBlock |
|
80 "this is meant to be sent by Signal only" |
|
81 |
|
82 rejectBlock := aBlock |
|
83 ! |
|
84 |
|
85 resumeBlock:aBlock |
|
86 "this is meant to be sent by Signal only" |
|
87 |
|
88 resumeBlock := aBlock |
|
89 ! ! |
|
90 |
|
91 !Exception methodsFor:'handler actions'! |
|
92 |
|
93 reject |
|
94 "handler decided not to handle this signal - |
|
95 system will look for another handler" |
|
96 |
|
97 rejectBlock value |
|
98 ! |
|
99 |
|
100 resume |
|
101 "Continue after the raise - the raise returns nil" |
|
102 |
|
103 resumeBlock value:nil |
|
104 ! |
|
105 |
|
106 resumeWith:value |
|
107 "Continue after the raise - the raise returns value" |
|
108 |
|
109 resumeBlock value:value |
|
110 ! |
|
111 |
|
112 proceed |
|
113 "Continue after the raise - the raise returns nil" |
|
114 |
|
115 resumeBlock value:nil |
|
116 ! |
|
117 |
|
118 proceedWith:value |
|
119 "Continue after the raise - the raise returns value" |
|
120 |
|
121 resumeBlock value:value |
|
122 ! |
|
123 |
|
124 return |
|
125 "Continue after the handle:do: - the handle:do: returns nil" |
|
126 |
|
127 handlerContext resume |
|
128 ! |
|
129 |
|
130 returnWith:value |
|
131 "Continue after the handle:do: - the handle:do: returns value" |
|
132 |
|
133 handlerContext resume:value |
|
134 ! |
|
135 |
|
136 restart |
|
137 "restart the handle:do: - usually after some repair work is done |
|
138 in handler" |
|
139 |
|
140 handlerContext restart |
|
141 ! ! |