author | Claus Gittinger <cg@exept.de> |
Tue, 03 Aug 1999 14:55:02 +0200 | |
changeset 4513 | b16770982c62 |
parent 4494 | e14f8ef4b860 |
child 4525 | 999e680a29ca |
permissions | -rw-r--r-- |
4466
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1 |
" |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
2 |
COPYRIGHT (c) 1999 by eXept Software AG |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
3 |
All Rights Reserved |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
4 |
|
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
5 |
This software is furnished under a license and may be used |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
10 |
hereby transferred. |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
11 |
" |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
12 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
13 |
|
4446 | 14 |
Exception subclass:#Query |
15 |
instanceVariableNames:'' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Kernel-Exceptions' |
|
19 |
! |
|
20 |
||
21 |
!Query class methodsFor:'documentation'! |
|
22 |
||
4466
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
23 |
copyright |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
24 |
" |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
25 |
COPYRIGHT (c) 1999 by eXept Software AG |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
26 |
All Rights Reserved |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
27 |
|
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
28 |
This software is furnished under a license and may be used |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
29 |
only in accordance with the terms of that license and with the |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
30 |
inclusion of the above copyright notice. This software may not |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
31 |
be provided or otherwise made available to, or used by, any |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
32 |
other person. No title to or ownership of the software is |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
33 |
hereby transferred. |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
34 |
" |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
35 |
|
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
36 |
! |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
37 |
|
4446 | 38 |
documentation |
39 |
" |
|
4466
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
40 |
Query is an abstract superclass of all query exceptions in the system |
4446 | 41 |
|
42 |
[author:] |
|
43 |
Stefan Vogel |
|
44 |
||
45 |
[see also:] |
|
46 |
Signal QuerySignal |
|
47 |
" |
|
48 |
||
49 |
! |
|
50 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
51 |
examples |
4446 | 52 |
" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
53 |
an up-query from a deeply nested operation to a higher level: |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
54 |
[exBegin] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
55 |
|zero| |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
56 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
57 |
zero := 0. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
58 |
Query handle:[:ex | |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
59 |
Transcript showCR:'query'. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
60 |
ex proceedWith:true |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
61 |
] do:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
62 |
'nesting'. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
63 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
64 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
65 |
Object errorSignal handle:[:ex | |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
66 |
Transcript showCR:'some error: ' , ex errorString. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
67 |
ex proceed |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
68 |
] do:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
69 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
70 |
1 // zero. 'an error which is caught in the handler'. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
71 |
(Query query) == true ifTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
72 |
Transcript showCR:'query says: ok'. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
73 |
] ifFalse:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
74 |
Transcript showCR:'query says: no' |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
75 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
76 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
77 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
78 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
79 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
80 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
81 |
[exEnd] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
82 |
for lazy typists, a more compact interface is also provided |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
83 |
(which is also easier to read): |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
84 |
[exBegin] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
85 |
Query answer:true do:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
86 |
'nesting'. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
87 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
88 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
89 |
(Query query) == true ifTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
90 |
Transcript showCR:'query says: ok'. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
91 |
] ifFalse:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
92 |
Transcript showCR:'query says: no' |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
93 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
94 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
95 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
96 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
97 |
[exEnd] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
98 |
an up-query from a deeply nested operation, for which there |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
99 |
is no handler: |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
100 |
(notice, this would not work with normal signals, which would raise |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
101 |
another unhandled exception-exception; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
102 |
also notice the == check #raise's return value being true, |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
103 |
instead of a simple ifTrue; this handles a nil-value from |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
104 |
the unhandled query) |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
105 |
[exBegin] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
106 |
|zero| |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
107 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
108 |
zero := 0. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
109 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
110 |
'nesting'. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
111 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
112 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
113 |
Object errorSignal handle:[:ex | |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
114 |
Transcript showCR:'some error: ' , ex errorString. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
115 |
ex proceed |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
116 |
] do:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
117 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
118 |
1 // zero. 'an error which is caught in the handler'. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
119 |
(Query raise) == true ifTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
120 |
Transcript showCR:'query says: ok'. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
121 |
] ifFalse:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
122 |
Transcript showCR:'query says: no' |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
123 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
124 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
125 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
126 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
127 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
128 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
129 |
[exEnd] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
130 |
counter-example, just to show that things would not work this way |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
131 |
with regular signals: |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
132 |
[exBegin] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
133 |
|signal| |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
134 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
135 |
signal := Signal new. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
136 |
'nesting deeply'. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
137 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
138 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
139 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
140 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
141 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
142 |
(signal raise) == true ifTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
143 |
Transcript showCR:'query says: ok'. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
144 |
] ifFalse:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
145 |
Transcript showCR:'query says: no' |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
146 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
147 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
148 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
149 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
150 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
151 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
152 |
[exEnd] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
153 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
154 |
except, by handling the unhandled exception |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
155 |
(but we think, that querySignals are easier to use and |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
156 |
better document the intent): |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
157 |
[exBegin] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
158 |
|signal| |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
159 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
160 |
signal := Signal new. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
161 |
'nesting deeply'. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
162 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
163 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
164 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
165 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
166 |
[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
167 |
Signal noHandlerSignal handle:[:ex | |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
168 |
ex proceedWith:nil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
169 |
] do:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
170 |
(signal raise) == true ifTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
171 |
Transcript showCR:'query says: ok'. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
172 |
] ifFalse:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
173 |
Transcript showCR:'query says: no' |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
174 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
175 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
176 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
177 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
178 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
179 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
180 |
] value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
181 |
[exEnd] |
4446 | 182 |
" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
183 |
|
4446 | 184 |
! ! |
185 |
||
186 |
!Query class methodsFor:'answering queries'! |
|
187 |
||
188 |
answer:someAnswer do:aBlock |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
189 |
"evaluate the argument, aBlock. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
190 |
If the receiver is queried during evaluation, answer with someAnswer. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
191 |
This is a wrapper for #handle:do: for lazy typists; no new functionality." |
4446 | 192 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
193 |
<exception: #handle> |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
194 |
|
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
195 |
"/ thisContext markForHandle. -- same as above pragma |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
196 |
aBlock value. "the real logic is in Exception>>doRaise" |
4446 | 197 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
198 |
" |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
199 |
Query answer:true do:[ |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
200 |
Transcript showCR:'query answers: ' , (Query query printString). |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
201 |
] |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
202 |
" |
4446 | 203 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
204 |
" |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
205 |
Query answer:false do:[ |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
206 |
Transcript showCR:'first query answers: ' , (Query query printString). |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
207 |
Query answer:true do:[ |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
208 |
Transcript showCR:'second query answers: ' , (Query query printString). |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
209 |
] |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
210 |
] |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
211 |
" |
4446 | 212 |
|
213 |
"Created: / 10.7.1996 / 15:08:20 / cg" |
|
214 |
"Modified: / 14.10.1996 / 16:59:18 / cg" |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
215 |
"Modified: / 25.7.1999 / 23:12:19 / stefan" |
4446 | 216 |
! ! |
217 |
||
218 |
!Query class methodsFor:'queries'! |
|
219 |
||
220 |
accepts:aSignal |
|
221 |
"return true, if the receiver accepts the argument, aSignal. |
|
222 |
(i.e. the receiver is aSignal or a parent of it). False otherwise." |
|
223 |
||
224 |
|s| |
|
225 |
||
226 |
aSignal isQuerySignal ifFalse:[^ false]. |
|
227 |
||
228 |
s := aSignal. |
|
229 |
[s notNil] whileTrue:[ |
|
230 |
self == s ifTrue:[^ true]. |
|
231 |
s := s parent |
|
232 |
]. |
|
233 |
^ false |
|
234 |
||
235 |
"Modified: / 22.3.1999 / 12:45:32 / stefan" |
|
236 |
"Created: / 23.7.1999 / 15:18:00 / stefan" |
|
237 |
! |
|
238 |
||
239 |
defaultAnswer |
|
240 |
"Return the default answer to the Query. This method is called, |
|
241 |
if nobody catches the signal. |
|
242 |
||
243 |
Subclasses may redefine this method." |
|
244 |
||
245 |
"Calling raiseRequest here will execute the exception's action method" |
|
246 |
||
247 |
^ super raiseRequest |
|
248 |
||
249 |
"Created: / 23.7.1999 / 15:16:03 / stefan" |
|
250 |
! |
|
251 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
252 |
handlerForSignal:signal context:theContext originator:originator |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
253 |
"answer the handler block for the signal from originator. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
254 |
The block is retrieved from aContext. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
255 |
Answer nil if the signal is not handled" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
256 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
257 |
|arg| |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
258 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
259 |
theContext selector == #'answer:do:' ifTrue:[ |
4513 | 260 |
(self == signal or:[self accepts:signal]) ifTrue:[ |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
261 |
arg := theContext argAt:1. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
262 |
^ [:ex| ex proceedWith:arg]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
263 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
264 |
] ifFalse:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
265 |
^ super handlerForSignal:signal context:theContext originator:originator. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
266 |
]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
267 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
268 |
^ nil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
269 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
270 |
"Created: / 25.7.1999 / 23:11:55 / stefan" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
271 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
272 |
|
4446 | 273 |
isQuerySignal |
274 |
||
275 |
^ true |
|
276 |
||
277 |
"Created: / 23.7.1999 / 14:59:50 / stefan" |
|
278 |
! |
|
279 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
280 |
query |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
281 |
"raise the query - return the handlers value, or the default |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
282 |
value, if there is no handler. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
283 |
Invoking the handler is exactly the functionality of Signal>>raiseRequest, |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
284 |
but we can do it faster here." |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
285 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
286 |
|con s| |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
287 |
|
4494
e14f8ef4b860
tuned #isHandledIn: and #query
Claus Gittinger <cg@exept.de>
parents:
4491
diff
changeset
|
288 |
con := Context findFirstSpecialHandle:true raise:false. |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
289 |
[con notNil] whileTrue:[ |
4494
e14f8ef4b860
tuned #isHandledIn: and #query
Claus Gittinger <cg@exept.de>
parents:
4491
diff
changeset
|
290 |
(con selector == #answer:do:) ifFalse:[ |
e14f8ef4b860
tuned #isHandledIn: and #query
Claus Gittinger <cg@exept.de>
parents:
4491
diff
changeset
|
291 |
^ super raiseRequest |
e14f8ef4b860
tuned #isHandledIn: and #query
Claus Gittinger <cg@exept.de>
parents:
4491
diff
changeset
|
292 |
]. |
e14f8ef4b860
tuned #isHandledIn: and #query
Claus Gittinger <cg@exept.de>
parents:
4491
diff
changeset
|
293 |
(s := con receiver) == self ifTrue:[ |
e14f8ef4b860
tuned #isHandledIn: and #query
Claus Gittinger <cg@exept.de>
parents:
4491
diff
changeset
|
294 |
^ con argAt:1 |
e14f8ef4b860
tuned #isHandledIn: and #query
Claus Gittinger <cg@exept.de>
parents:
4491
diff
changeset
|
295 |
]. |
4513 | 296 |
(s == self or:[s accepts:self]) ifTrue:[ |
4494
e14f8ef4b860
tuned #isHandledIn: and #query
Claus Gittinger <cg@exept.de>
parents:
4491
diff
changeset
|
297 |
^ super raiseRequest |
e14f8ef4b860
tuned #isHandledIn: and #query
Claus Gittinger <cg@exept.de>
parents:
4491
diff
changeset
|
298 |
]. |
e14f8ef4b860
tuned #isHandledIn: and #query
Claus Gittinger <cg@exept.de>
parents:
4491
diff
changeset
|
299 |
con := con findSpecialHandle:true raise:false. |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
300 |
]. |
4494
e14f8ef4b860
tuned #isHandledIn: and #query
Claus Gittinger <cg@exept.de>
parents:
4491
diff
changeset
|
301 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
302 |
"/ no handler found - return the default value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
303 |
^ self defaultAnswer |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
304 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
305 |
"Modified: / 15.6.1998 / 21:27:37 / cg" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
306 |
"Modified: / 25.7.1999 / 23:15:16 / stefan" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
307 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
308 |
|
4446 | 309 |
raise |
310 |
"QuerySignals are proceedable by definition, |
|
311 |
so they should be raised with #query or #raiseRequest" |
|
312 |
||
313 |
^ self shouldNotImplement |
|
314 |
||
315 |
"Created: / 23.7.1999 / 15:19:17 / stefan" |
|
316 |
! |
|
317 |
||
318 |
raiseRequest |
|
319 |
"redefined to use #query" |
|
320 |
||
321 |
^ self query |
|
322 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4446
diff
changeset
|
323 |
"Created: / 25.7.1999 / 23:25:59 / stefan" |
4446 | 324 |
! ! |
325 |
||
326 |
!Query methodsFor:'default actions'! |
|
327 |
||
328 |
action |
|
329 |
"the default action is to return the default value. |
|
330 |
Subclasses may redefine this" |
|
331 |
||
332 |
^ nil |
|
333 |
||
334 |
"Modified: / 23.7.1999 / 15:13:34 / stefan" |
|
335 |
! ! |
|
336 |
||
337 |
!Query class methodsFor:'documentation'! |
|
338 |
||
339 |
version |
|
4513 | 340 |
^ '$Header: /cvs/stx/stx/libbasic/Query.st,v 1.6 1999-08-03 12:53:14 cg Exp $' |
4446 | 341 |
! ! |