ZeroDivide.st
author Jan Vrany <jan.vrany@labware.com>
Tue, 01 Jun 2021 20:19:13 +0100
branchjv
changeset 25424 51bd8a6b196f
parent 23547 c69c97cec351
permissions -rw-r--r--
Cherry-picked `Context` cherry-picked Context.st from a6b6dda4caff: * 4aaf30c174e9: #DOCUMENTATION by cg, Claus Gittinger <cg@exept.de> * c67311afcc6c: #OTHER by cg, Claus Gittinger <cg@exept.de> * 883f79e7b2a6: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 716f3fbb09e9: Don't mark contexts with `CATCHMARK`, Jan Vrany <jan.vrany@fit.cvut.cz> * cff24fa817b0: #REFACTORING by stefan, Stefan Vogel <sv@exept.de> * 521f0d837330: #UI_ENHANCEMENT by cg, Claus Gittinger <cg@exept.de> * bf1118f0fcca: #UI_ENHANCEMENT by cg, Claus Gittinger <cg@exept.de> * e587cdd22868: #BUGFIX by cg, Claus Gittinger <cg@exept.de> * fe9f9487a3ed: #DOCUMENTATION by cg, Claus Gittinger <cg@exept.de> * d5b781899274: #BUGFIX by cg, Claus Gittinger <cg@exept.de> * 8258751a7465: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 40173e082cbc: Copyright updates, Jan Vrany <jan.vrany@fit.cvut.cz> * 6db5c28207d5: #UI_ENHANCEMENT by cg, Claus Gittinger <cg@exept.de> * 871ea64fd5dc: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 4b544a108e4e: #DOCUMENTATION by cg, Claus Gittinger <cg@exept.de> * 9a8d8399e566: #FEATURE by cgexept.de, Claus Gittinger <cg@exept.de> * 170b00be0103: #BUGFIX by stefan, Stefan Vogel <sv@exept.de> * a6c73965eae8: #FEATURE by cg, Claus Gittinger <cg@exept.de> * ce2a0e462ff0: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 46a260a9ca92: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 46cab49167fb: #UI_ENHANCEMENT by exept, Claus Gittinger <cg@exept.de> * 7d52dfd3997d: #DOCUMENTATION by exept, Claus Gittinger <cg@exept.de> * c52eeea62763: Fix `Context >> argAndVarNames` in cases when debug info is not available, Jan Vrany <jan.vrany@labware.com> * b5d6963fe4a9: Backed out changeset c52eeea62763, Jan Vrany <jan.vrany@labware.com> * 6fd3896f8703: #FEATURE by exept, Claus Gittinger <cg@exept.de> * b530ee616256: #REFACTORING by cg, Claus Gittinger <cg@exept.de> * ef9b481d7498: #FEATURE by cg, Claus Gittinger <cg@exept.de> * ea663b72bd51: #UI_ENHANCEMENT by cg, Claus Gittinger <cg@exept.de> * 6179572a733c: #FEATURE by exept, Claus Gittinger <cg@exept.de> * 84155b1b6622: #DOCUMENTATION by exept, Claus Gittinger <cg@exept.de> * 37d06602d856: *** empty log message ***, Claus Gittinger <cg@exept.de> * f927b9022fea: *** empty log message ***, Claus Gittinger <cg@exept.de> * 427d3be62d97: #UI_ENHANCEMENT by exept, Claus Gittinger <cg@exept.de>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7585
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     1
"
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     2
 COPYRIGHT (c) 2001 by eXept Software AG
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     3
              All Rights Reserved
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     4
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     5
 This software is furnished under a license and may be used
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     6
 only in accordance with the terms of that license and with the
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     8
 be provided or otherwise made available to, or used by, any
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     9
 other person.  No title to or ownership of the software is
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    10
 hereby transferred.
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    11
"
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic' }"
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
20458
55727803f73d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 14717
diff changeset
    14
"{ NameSpace: Smalltalk }"
55727803f73d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 14717
diff changeset
    15
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
DomainError subclass:#ZeroDivide
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:''
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:''
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
6218
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    20
	category:'Kernel-Exceptions-Errors'
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
6218
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    23
!ZeroDivide class methodsFor:'documentation'!
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    24
7585
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    25
copyright
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    26
"
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    27
 COPYRIGHT (c) 2001 by eXept Software AG
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    28
              All Rights Reserved
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    29
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    30
 This software is furnished under a license and may be used
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    31
 only in accordance with the terms of that license and with the
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    33
 be provided or otherwise made available to, or used by, any
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    34
 other person.  No title to or ownership of the software is
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    35
 hereby transferred.
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    36
"
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    37
!
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    38
6218
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    39
documentation
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    40
"
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    41
    Raised when a division by zero is attempted.
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    42
"
7584
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    43
!
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    44
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    45
examples
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    46
"
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    47
    the following leads into a debugger:
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    48
                                                                    [exBegin]
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    49
        |divisor|
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    50
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    51
        divisor := 0.
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    52
        Transcript showCR: ( 5 / divisor ).
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    53
                                                                    [exEnd]
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    54
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    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
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    57
                                                                    [exBegin]
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    58
        |divisor|
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    59
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    60
        divisor := 0.
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    61
        [
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    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
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    66
                                                                    [exEnd]
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    67
"
6218
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    68
! !
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
18017
7fef9e17913f Merged 956be83322ff and 8657c48a4c03 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911 14717
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>
parents: 17911 14717
diff changeset
    77
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
!ZeroDivide methodsFor:'accessing'!
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
14717
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    80
defaultResumeValue
20458
55727803f73d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 14717
diff changeset
    81
    "return infinity here, if ever proceeded"
14717
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    82
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    83
    ^ parameter receiver class infinity
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    84
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    85
    "
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    86
     |a b|
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    87
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    88
     a := 5.
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    89
     b := 0.
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    90
     ZeroDivide handle:[:ex |
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    91
        Transcript showCR:('division by zero - dividend was: ' , ex dividend printString).
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    92
        ex proceed
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    93
     ] do:[
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    94
        a / b
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    95
     ]            
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    96
    "
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    97
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    98
    "
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    99
     |a b|
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   100
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   101
     a := 5.0.
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   102
     b := 0.0.
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   103
     ZeroDivide handle:[:ex |
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   104
        Transcript showCR:('division by zero - dividend was: ' , ex dividend printString).
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   105
        ex proceed
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   106
     ] do:[
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   107
        a / b
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   108
     ]            
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   109
    "
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   110
!
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   111
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
dividend
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    "Return the number that was being divided by zero."
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
5969
ed98cd153ecc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5947
diff changeset
   115
    ^ parameter receiver
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    "
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
     |a b|
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
     a := 5.
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
     b := 0.
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
     Integer divisionByZeroSignal handle:[:ex |
5969
ed98cd153ecc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5947
diff changeset
   123
        Transcript showCR:('division by zero - dividend was: ' , ex dividend printString)
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
     ] do:[
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
        a // b
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
     ]
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    "
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
! !
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
18017
7fef9e17913f Merged 956be83322ff and 8657c48a4c03 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911 14717
diff changeset
   130
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
!ZeroDivide class methodsFor:'documentation'!
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
version
20458
55727803f73d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 14717
diff changeset
   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
a99f15c5efa5 Updated with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17910
diff changeset
   138
    ^ '$Id: ZeroDivide.st 10761 2012-01-19 11:46:00Z vranyj1 $'
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
! !
7584
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
   140
14717
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   141
6690
07ef28245da8 notifier now initialized here
Claus Gittinger <cg@exept.de>
parents: 6218
diff changeset
   142
ZeroDivide initialize!