author | Claus Gittinger <cg@exept.de> |
Mon, 13 Feb 2017 20:44:07 +0100 | |
changeset 21434 | e9cd145acfa9 |
parent 20458 | 55727803f73d |
child 20578 | 39641ba8d6e0 |
child 21863 | fca2a068f458 |
permissions | -rw-r--r-- |
20458 | 1 |
"{ Encoding: utf8 }" |
2 |
||
7585 | 3 |
" |
4 |
COPYRIGHT (c) 2001 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 |
" |
|
5947 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
20458 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
5947 | 18 |
DomainError subclass:#ZeroDivide |
19 |
instanceVariableNames:'' |
|
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
6218 | 22 |
category:'Kernel-Exceptions-Errors' |
5947 | 23 |
! |
24 |
||
6218 | 25 |
!ZeroDivide class methodsFor:'documentation'! |
26 |
||
7585 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 2001 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 |
||
6218 | 41 |
documentation |
42 |
" |
|
43 |
Raised when a division by zero is attempted. |
|
44 |
" |
|
7584 | 45 |
! |
46 |
||
47 |
examples |
|
48 |
" |
|
49 |
the following leads into a debugger: |
|
50 |
[exBegin] |
|
51 |
|divisor| |
|
52 |
||
53 |
divisor := 0. |
|
54 |
Transcript showCR: ( 5 / divisor ). |
|
55 |
[exEnd] |
|
56 |
||
57 |
||
10273
84eddf61acc5
Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents:
7585
diff
changeset
|
58 |
the following does NOT lead into a debugger: |
7584 | 59 |
[exBegin] |
60 |
|divisor| |
|
61 |
||
62 |
divisor := 0. |
|
63 |
[ |
|
64 |
Transcript showCR: ( 5 / divisor ). |
|
10273
84eddf61acc5
Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents:
7585
diff
changeset
|
65 |
] on:ZeroDivide do:[ |
84eddf61acc5
Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents:
7585
diff
changeset
|
66 |
Transcript flash. |
84eddf61acc5
Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents:
7585
diff
changeset
|
67 |
] |
7584 | 68 |
[exEnd] |
69 |
" |
|
6218 | 70 |
! ! |
5947 | 71 |
|
6690
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
72 |
!ZeroDivide class methodsFor:'initialization'! |
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
73 |
|
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
74 |
initialize |
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
75 |
NotifierString := 'division by zero'. |
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
76 |
! ! |
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
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 |
||
130 |
!ZeroDivide class methodsFor:'documentation'! |
|
131 |
||
132 |
version |
|
20458 | 133 |
^ '$Header$' |
5947 | 134 |
! ! |
7584 | 135 |
|
14717 | 136 |
|
6690
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
137 |
ZeroDivide initialize! |