ZeroDivide.st
author Claus Gittinger <cg@exept.de>
Fri, 15 Sep 2006 19:52:31 +0200
changeset 9908 eede5b535b1e
parent 7585 87d76b40f897
child 10273 84eddf61acc5
permissions -rw-r--r--
extensions sorted by name (to avoid confusing cvs-diff)
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
"
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    12
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"{ Package: 'stx:libbasic' }"
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
DomainError subclass:#ZeroDivide
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	instanceVariableNames:''
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	classVariableNames:''
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	poolDictionaries:''
6218
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    19
	category:'Kernel-Exceptions-Errors'
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
6218
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    22
!ZeroDivide class methodsFor:'documentation'!
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    23
7585
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    24
copyright
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    25
"
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    26
 COPYRIGHT (c) 2001 by eXept Software AG
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    27
              All Rights Reserved
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    28
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    29
 This software is furnished under a license and may be used
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    30
 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
    31
 inclusion of the above copyright notice.   This software may not
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    32
 be provided or otherwise made available to, or used by, any
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    33
 other person.  No title to or ownership of the software is
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    34
 hereby transferred.
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    35
"
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
6218
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    38
documentation
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    39
"
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    40
    Raised when a division by zero is attempted.
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    41
"
7584
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    42
!
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    43
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    44
examples
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    45
"
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    46
    the following leads into a debugger:
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    47
                                                                    [exBegin]
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    48
        |divisor|
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    49
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    50
        divisor := 0.
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    51
        Transcript showCR: ( 5 / divisor ).
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    52
                                                                    [exEnd]
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    53
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    54
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    55
    the following does NOT leads into a debugger:
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    56
                                                                    [exBegin]
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    57
        |divisor|
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    58
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    59
        divisor := 0.
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    60
        [
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    61
            Transcript showCR: ( 5 / divisor ).
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    62
        ] on:ZeroDivide 
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    63
            do:
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    64
                [
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    65
                    Transcript flash.
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    66
                ]
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    67
                                                                    [exEnd]
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    68
"
6218
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    69
! !
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
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
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
!ZeroDivide methodsFor:'accessing'!
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
dividend
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    "Return the number that was being divided by zero."
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
5969
ed98cd153ecc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5947
diff changeset
    82
    ^ parameter receiver
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    "
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
     |a b|
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
     a := 5.
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
     b := 0.
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
     Integer divisionByZeroSignal handle:[:ex |
5969
ed98cd153ecc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5947
diff changeset
    90
        Transcript showCR:('division by zero - dividend was: ' , ex dividend printString)
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
     ] do:[
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
        a // b
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
     ]
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    "
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
! !
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
!ZeroDivide class methodsFor:'documentation'!
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
version
7585
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
   100
    ^ '$Header: /cvs/stx/stx/libbasic/ZeroDivide.st,v 1.6 2003-08-29 19:10:23 cg Exp $'
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
! !
7584
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
   102
6690
07ef28245da8 notifier now initialized here
Claus Gittinger <cg@exept.de>
parents: 6218
diff changeset
   103
ZeroDivide initialize!