(self, e)
Handle Overflow or Division by Zero.
Handle Overflow or Division by Zero.
Handle Overflow or Division by Zero .
def handle(self, e):
        """Handle Overflow or Division by Zero."""
        if isinstance(e, ValueError):
            # math domain errors such as SQR(-1)
            math_error = error.IFC
        elif isinstance(e, OverflowError):
            math_error = error.OVERFLOW
        elif isinstance(e, ZeroDivisionError):
            math_error = error.DIVISION_BY_ZERO
        else: # pragma: no cover
            # shouldn't happen, we're only called with ValueError/ArithmeticError
            raise e
        if (self._do_raise or self._console is None or math_error not in self.soft_types):
            # also raises exception in error_handle_mode!
            # in that case, prints a normal error message
            raise error.BASICError(math_error)
        else:
            # write a message & continue as normal
            # message should not include line number or trailing \xFF
            self._console.write_line(error.BASICError(math_error).message)
        # return max value for the appropriate float type
        # integer operations should just raise the BASICError directly, they are not handled
        if e.args and isinstance(e.args[0], numbers.Float):
            return e.args[0]
        else: # pragma: no cover
            return numbers.Single(None, self).from_bytes(numbers.Single.pos_max)
def handle ( self , e ) : if isinstance ( e , ValueError ) : # math domain errors such as SQR(-1) math_error = error . IFC elif isinstance ( e , OverflowError ) : math_error = error . OVERFLOW elif isinstance ( e , ZeroDivisionError ) : math_error = error . DIVISION_BY_ZERO else : # pragma: no cover # shouldn't happen, we're only called with ValueError/ArithmeticError raise e if ( self . _do_raise or self . _console is None or math_error not in self . soft_types ) : # also raises exception in error_handle_mode! # in that case, prints a normal error message raise error . BASICError ( math_error ) else : # write a message & continue as normal # message should not include line number or trailing \xFF self . _console . write_line ( error . BASICError ( math_error ) . message ) # return max value for the appropriate float type # integer operations should just raise the BASICError directly, they are not handled if e . args and isinstance ( e . args [ 0 ] , numbers . Float ) : return e . args [ 0 ] else : # pragma: no cover return numbers . Single ( None , self ) . from_bytes ( numbers . Single . pos_max )