Table of Contents

Class ArithmeticError

Namespace
NumSharp
Assembly
NumSharp.dll

Python's ArithmeticError: the base of the numeric failures OverflowError, ZeroDivisionError and FloatingPointError. Catch it to handle all three at once, as except ArithmeticError does.

public class ArithmeticError : ArithmeticException, ISerializable, INumSharpException
Inheritance
ArithmeticError
Implements
Derived
Inherited Members

Remarks

It derives from .NET's ArithmeticException, the exception with the same meaning, so a catch (ArithmeticException) written for .NET code catches NumSharp's Python arithmetic errors too.

Footgun: its subclasses are NOT .NET's OverflowException / DivideByZeroException (both are .NET siblings of this class under ArithmeticException), so a catch (OverflowException) does not see an OverflowError. NumSharp raises the Python classes wherever NumPy or CPython raises them; .NET's own exceptions stay for what .NET itself refuses (a checked conversion inside NumSharp, a Char8 conversion out of range).

Constructors

ArithmeticError()

Creates the error with Python's text for a bare raise ArithmeticError: an empty Message, as str(ArithmeticError()) is '' (not .NET's ArithmeticException default, "Overflow or underflow in the arithmetic operation.").

public ArithmeticError()

Remarks

ToString() then starts with the class name alone, as Python's traceback prints a bare ArithmeticError.

ArithmeticError(string)

Creates the error with NumPy's (or the port's) message.

public ArithmeticError(string message)

Parameters

message string

The text, verbatim: Python's str() of the error.

ArithmeticError(string, Exception)

Creates the error with a message and the exception that caused it: Python's raise ArithmeticError(message) from innerException, the cause kept in InnerException as Python keeps it in cause.

public ArithmeticError(string message, Exception innerException)

Parameters

message string

The text, verbatim: Python's str() of the error.

innerException Exception

The exception that led to this one, or null for none.