author | Jan Vrany <jan.vrany@labware.com> |
Thu, 25 Mar 2021 20:30:03 +0000 | |
branch | jv |
changeset 25411 | 248600ba8fd9 |
parent 23547 | c69c97cec351 |
permissions | -rw-r--r-- |
7585 | 1 |
" |
2 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
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 |
" |
|
5947 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
20458 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
5947 | 16 |
DomainError subclass:#ZeroDivide |
17 |
instanceVariableNames:'' |
|
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
6218 | 20 |
category:'Kernel-Exceptions-Errors' |
5947 | 21 |
! |
22 |
||
6218 | 23 |
!ZeroDivide class methodsFor:'documentation'! |
24 |
||
7585 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
6218 | 39 |
documentation |
40 |
" |
|
41 |
Raised when a division by zero is attempted. |
|
42 |
" |
|
7584 | 43 |
! |
44 |
||
45 |
examples |
|
46 |
" |
|
47 |
the following leads into a debugger: |
|
48 |
[exBegin] |
|
49 |
|divisor| |
|
50 |
||
51 |
divisor := 0. |
|
52 |
Transcript showCR: ( 5 / divisor ). |
|
53 |
[exEnd] |
|
54 |
||
55 |
||
10273
84eddf61acc5
Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents:
7585
diff
changeset
|
56 |
the following does NOT lead into a debugger: |
7584 | 57 |
[exBegin] |
58 |
|divisor| |
|
59 |
||
60 |
divisor := 0. |
|
61 |
[ |
|
62 |
Transcript showCR: ( 5 / divisor ). |
|
10273
84eddf61acc5
Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents:
7585
diff
changeset
|
63 |
] on:ZeroDivide do:[ |
84eddf61acc5
Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents:
7585
diff
changeset
|
64 |
Transcript flash. |
84eddf61acc5
Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents:
7585
diff
changeset
|
65 |
] |
7584 | 66 |
[exEnd] |
67 |
" |
|
6218 | 68 |
! ! |
5947 | 69 |
|
18017
7fef9e17913f
Merged 956be83322ff and 8657c48a4c03 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
70 |
|
6690
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
71 |
!ZeroDivide class methodsFor:'initialization'! |
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
72 |
|
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
73 |
initialize |
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
74 |
NotifierString := 'division by zero'. |
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
75 |
! ! |
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
76 |
|
18017
7fef9e17913f
Merged 956be83322ff and 8657c48a4c03 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
77 |
|
5947 | 78 |
!ZeroDivide methodsFor:'accessing'! |
79 |
||
14717 | 80 |
defaultResumeValue |
20458 | 81 |
"return infinity here, if ever proceeded" |
14717 | 82 |
|
83 |
^ parameter receiver class infinity |
|
84 |
||
85 |
" |
|
86 |
|a b| |
|
87 |
||
88 |
a := 5. |
|
89 |
b := 0. |
|
90 |
ZeroDivide handle:[:ex | |
|
91 |
Transcript showCR:('division by zero - dividend was: ' , ex dividend printString). |
|
92 |
ex proceed |
|
93 |
] do:[ |
|
94 |
a / b |
|
95 |
] |
|
96 |
" |
|
97 |
||
98 |
" |
|
99 |
|a b| |
|
100 |
||
101 |
a := 5.0. |
|
102 |
b := 0.0. |
|
103 |
ZeroDivide handle:[:ex | |
|
104 |
Transcript showCR:('division by zero - dividend was: ' , ex dividend printString). |
|
105 |
ex proceed |
|
106 |
] do:[ |
|
107 |
a / b |
|
108 |
] |
|
109 |
" |
|
110 |
! |
|
111 |
||
5947 | 112 |
dividend |
113 |
"Return the number that was being divided by zero." |
|
114 |
||
5969 | 115 |
^ parameter receiver |
5947 | 116 |
|
117 |
" |
|
118 |
|a b| |
|
119 |
||
120 |
a := 5. |
|
121 |
b := 0. |
|
122 |
Integer divisionByZeroSignal handle:[:ex | |
|
5969 | 123 |
Transcript showCR:('division by zero - dividend was: ' , ex dividend printString) |
5947 | 124 |
] do:[ |
125 |
a // b |
|
126 |
] |
|
127 |
" |
|
128 |
! ! |
|
129 |
||
18017
7fef9e17913f
Merged 956be83322ff and 8657c48a4c03 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
130 |
|
5947 | 131 |
!ZeroDivide class methodsFor:'documentation'! |
132 |
||
133 |
version |
|
20458 | 134 |
^ '$Header$' |
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
135 |
! |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
136 |
|
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
137 |
version_SVN |
17911 | 138 |
^ '$Id: ZeroDivide.st 10761 2012-01-19 11:46:00Z vranyj1 $' |
5947 | 139 |
! ! |
7584 | 140 |
|
14717 | 141 |
|
6690
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
142 |
ZeroDivide initialize! |