author | Stefan Vogel <sv@exept.de> |
Mon, 08 Jun 2015 17:51:54 +0200 | |
changeset 18463 | 8c5f3917b2e8 |
parent 14717 | 8bd5b56dd171 |
child 18017 | 7fef9e17913f |
child 20458 | 55727803f73d |
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 |
||
14 |
DomainError subclass:#ZeroDivide |
|
15 |
instanceVariableNames:'' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
6218 | 18 |
category:'Kernel-Exceptions-Errors' |
5947 | 19 |
! |
20 |
||
6218 | 21 |
!ZeroDivide class methodsFor:'documentation'! |
22 |
||
7585 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
6218 | 37 |
documentation |
38 |
" |
|
39 |
Raised when a division by zero is attempted. |
|
40 |
" |
|
7584 | 41 |
! |
42 |
||
43 |
examples |
|
44 |
" |
|
45 |
the following leads into a debugger: |
|
46 |
[exBegin] |
|
47 |
|divisor| |
|
48 |
||
49 |
divisor := 0. |
|
50 |
Transcript showCR: ( 5 / divisor ). |
|
51 |
[exEnd] |
|
52 |
||
53 |
||
10273
84eddf61acc5
Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents:
7585
diff
changeset
|
54 |
the following does NOT lead into a debugger: |
7584 | 55 |
[exBegin] |
56 |
|divisor| |
|
57 |
||
58 |
divisor := 0. |
|
59 |
[ |
|
60 |
Transcript showCR: ( 5 / divisor ). |
|
10273
84eddf61acc5
Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents:
7585
diff
changeset
|
61 |
] on:ZeroDivide do:[ |
84eddf61acc5
Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents:
7585
diff
changeset
|
62 |
Transcript flash. |
84eddf61acc5
Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents:
7585
diff
changeset
|
63 |
] |
7584 | 64 |
[exEnd] |
65 |
" |
|
6218 | 66 |
! ! |
5947 | 67 |
|
6690
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
68 |
!ZeroDivide class methodsFor:'initialization'! |
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
69 |
|
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
70 |
initialize |
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
71 |
NotifierString := 'division by zero'. |
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 |
|
5947 | 74 |
!ZeroDivide methodsFor:'accessing'! |
75 |
||
14717 | 76 |
defaultResumeValue |
77 |
"no, we return infinity here, if ever proceeded" |
|
78 |
||
79 |
^ parameter receiver class infinity |
|
80 |
||
81 |
" |
|
82 |
|a b| |
|
83 |
||
84 |
a := 5. |
|
85 |
b := 0. |
|
86 |
ZeroDivide handle:[:ex | |
|
87 |
Transcript showCR:('division by zero - dividend was: ' , ex dividend printString). |
|
88 |
ex proceed |
|
89 |
] do:[ |
|
90 |
a / b |
|
91 |
] |
|
92 |
" |
|
93 |
||
94 |
" |
|
95 |
|a b| |
|
96 |
||
97 |
a := 5.0. |
|
98 |
b := 0.0. |
|
99 |
ZeroDivide handle:[:ex | |
|
100 |
Transcript showCR:('division by zero - dividend was: ' , ex dividend printString). |
|
101 |
ex proceed |
|
102 |
] do:[ |
|
103 |
a / b |
|
104 |
] |
|
105 |
" |
|
106 |
! |
|
107 |
||
5947 | 108 |
dividend |
109 |
"Return the number that was being divided by zero." |
|
110 |
||
5969 | 111 |
^ parameter receiver |
5947 | 112 |
|
113 |
" |
|
114 |
|a b| |
|
115 |
||
116 |
a := 5. |
|
117 |
b := 0. |
|
118 |
Integer divisionByZeroSignal handle:[:ex | |
|
5969 | 119 |
Transcript showCR:('division by zero - dividend was: ' , ex dividend printString) |
5947 | 120 |
] do:[ |
121 |
a // b |
|
122 |
] |
|
123 |
" |
|
124 |
! ! |
|
125 |
||
126 |
!ZeroDivide class methodsFor:'documentation'! |
|
127 |
||
128 |
version |
|
14717 | 129 |
^ '$Header: /cvs/stx/stx/libbasic/ZeroDivide.st,v 1.8 2013-01-25 17:19:34 cg Exp $' |
5947 | 130 |
! ! |
7584 | 131 |
|
14717 | 132 |
|
6690
07ef28245da8
notifier now initialized here
Claus Gittinger <cg@exept.de>
parents:
6218
diff
changeset
|
133 |
ZeroDivide initialize! |