22941
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
15694
|
3 |
"
|
|
4 |
COPYRIGHT (c) 2013 by eXept Software AG
|
|
5 |
All Rights Reserved
|
|
6 |
|
|
7 |
This software is furnished under a license and may be used
|
|
8 |
only in accordance with the terms of that license and with the
|
|
9 |
inclusion of the above copyright notice. This software may not
|
|
10 |
be provided or otherwise made available to, or used by, any
|
|
11 |
other person. No title to or ownership of the software is
|
|
12 |
hereby transferred.
|
|
13 |
"
|
|
14 |
"{ Package: 'stx:libbasic' }"
|
|
15 |
|
21664
|
16 |
"{ NameSpace: Smalltalk }"
|
|
17 |
|
15694
|
18 |
Notification subclass:#ProceedingNotification
|
|
19 |
instanceVariableNames:''
|
|
20 |
classVariableNames:''
|
|
21 |
poolDictionaries:''
|
|
22 |
category:'Kernel-Exceptions'
|
|
23 |
!
|
|
24 |
|
|
25 |
!ProceedingNotification class methodsFor:'documentation'!
|
|
26 |
|
|
27 |
copyright
|
|
28 |
"
|
|
29 |
COPYRIGHT (c) 2013 by eXept Software AG
|
|
30 |
All Rights Reserved
|
|
31 |
|
|
32 |
This software is furnished under a license and may be used
|
|
33 |
only in accordance with the terms of that license and with the
|
|
34 |
inclusion of the above copyright notice. This software may not
|
|
35 |
be provided or otherwise made available to, or used by, any
|
|
36 |
other person. No title to or ownership of the software is
|
|
37 |
hereby transferred.
|
|
38 |
"
|
|
39 |
!
|
|
40 |
|
|
41 |
documentation
|
|
42 |
"
|
|
43 |
A ProceedingNotification behaves much like a regular notification,
|
|
44 |
in that if no handler is present, execution proceeds after the raise.
|
|
45 |
However, iff a handler simply falls through, the exception is proceeded.
|
|
46 |
The handler is still free to choose for an explicit action (return/reject).
|
|
47 |
|
|
48 |
[author:]
|
|
49 |
Claus Gittinger
|
|
50 |
|
|
51 |
[see also:]
|
|
52 |
Exception Query Notification
|
|
53 |
"
|
|
54 |
!
|
|
55 |
|
|
56 |
examples
|
|
57 |
"
|
22941
|
58 |
Notice, that in contrast to a regular Notification, the execution proceeds after the Notification:
|
15694
|
59 |
[exBegin]
|
|
60 |
|zero|
|
|
61 |
|
|
62 |
zero := 0.
|
22941
|
63 |
ProceedingNotification handle:[:n |
|
|
64 |
Transcript showCR:'h: ' , n description.
|
15694
|
65 |
] do:[
|
22941
|
66 |
Error handle:[:ex |
|
|
67 |
Transcript showCR:'some error: ' , ex errorString.
|
|
68 |
ex proceed
|
15694
|
69 |
] do:[
|
22941
|
70 |
[
|
|
71 |
|answer|
|
15694
|
72 |
|
22941
|
73 |
1 // zero. 'an error which is caught in the handler'.
|
|
74 |
answer := ProceedingNotification notify:'hello world'.
|
|
75 |
Transcript show:'after notification: '; showCR:answer.
|
|
76 |
] value
|
|
77 |
]
|
15694
|
78 |
].
|
|
79 |
[exEnd]
|
22941
|
80 |
|
|
81 |
however, if the handler returns, this is not the case:
|
15694
|
82 |
[exBegin]
|
|
83 |
|zero|
|
|
84 |
|
|
85 |
zero := 0.
|
22941
|
86 |
ProceedingNotification handle:[:n |
|
|
87 |
Transcript showCR:'h: ' , n description.
|
|
88 |
n return.
|
15694
|
89 |
] do:[
|
22941
|
90 |
Error handle:[:ex |
|
|
91 |
Transcript showCR:'some error: ' , ex errorString.
|
|
92 |
ex proceed
|
15694
|
93 |
] do:[
|
22941
|
94 |
[
|
|
95 |
|answer|
|
15694
|
96 |
|
22941
|
97 |
1 // zero. 'an error which is caught in the handler'.
|
|
98 |
answer := ProceedingNotification notify:'hello world'.
|
|
99 |
Transcript show:'after notification 1: '; showCR:answer.
|
|
100 |
] value
|
|
101 |
]
|
15694
|
102 |
].
|
|
103 |
[exEnd]
|
|
104 |
"
|
|
105 |
! !
|
|
106 |
|
|
107 |
!ProceedingNotification class methodsFor:'initialization'!
|
|
108 |
|
|
109 |
initialize
|
|
110 |
|
|
111 |
NotifierString := 'Notification:'
|
|
112 |
! !
|
|
113 |
|
|
114 |
!ProceedingNotification methodsFor:'default actions'!
|
|
115 |
|
|
116 |
doCallHandler:aHandlerBlock
|
|
117 |
"call the handler proper - if the handler falls through, proceed with the handler's value.
|
|
118 |
- an extra method is needed to have a raise-marked context around.
|
|
119 |
(see implementation of #reject and #proceed)."
|
|
120 |
|
|
121 |
<context: #return>
|
|
122 |
<exception: #raise>
|
|
123 |
|
|
124 |
|val|
|
|
125 |
|
21664
|
126 |
(aHandlerBlock isBlockWithArgumentCount:1) ifTrue:[
|
|
127 |
"1-arg handler - pass myself as exception argument"
|
|
128 |
val := aHandlerBlock value:self.
|
|
129 |
] ifFalse:[
|
15694
|
130 |
"0-arg handler or any object - not interested in the exception argument"
|
|
131 |
val := aHandlerBlock value
|
|
132 |
].
|
|
133 |
|
|
134 |
"handler fall through - this is different here!!"
|
21664
|
135 |
self proceedWith:val
|
15694
|
136 |
|
21664
|
137 |
"Modified (format): / 18-03-2017 / 18:27:22 / stefan"
|
15694
|
138 |
! !
|
|
139 |
|
|
140 |
!ProceedingNotification class methodsFor:'documentation'!
|
|
141 |
|
|
142 |
version
|
21664
|
143 |
^ '$Header$'
|
15694
|
144 |
!
|
|
145 |
|
|
146 |
version_CVS
|
21664
|
147 |
^ '$Header$'
|
15694
|
148 |
! !
|
|
149 |
|
|
150 |
|
|
151 |
ProceedingNotification initialize!
|