C# Class Python.Runtime.Exceptions

Encapsulates the Python exception APIs.
Show file Open project: pythonnet/pythonnet Class Usage Examples

Public Properties

Property Type Description
ArithmeticError System.IntPtr
AssertionError System.IntPtr
AttributeError System.IntPtr
BaseException System.IntPtr
DeprecationWarning System.IntPtr
EOFError System.IntPtr
EnvironmentError System.IntPtr
Exception System.IntPtr
FloatingPointError System.IntPtr
FutureWarning System.IntPtr
GeneratorExit System.IntPtr
IOError System.IntPtr
ImportError System.IntPtr
ImportWarning System.IntPtr
IndentationError System.IntPtr
IndexError System.IntPtr
KeyError System.IntPtr
KeyboardInterrupt System.IntPtr
LookupError System.IntPtr
MemoryError System.IntPtr
NameError System.IntPtr
NotImplementedError System.IntPtr
OSError System.IntPtr
OverflowError System.IntPtr
PendingDeprecationWarning System.IntPtr
ReferenceError System.IntPtr
RuntimeError System.IntPtr
RuntimeWarning System.IntPtr
StandardError System.IntPtr
StopIteration System.IntPtr
SyntaxError IntPtr
SyntaxWarning IntPtr
SystemError IntPtr
SystemExit IntPtr
TabError IntPtr
TypeError IntPtr
UnboundLocalError IntPtr
UnicodeDecodeError IntPtr
UnicodeEncodeError IntPtr
UnicodeError IntPtr
UnicodeTranslateError IntPtr
UnicodeWarning IntPtr
UserWarning IntPtr
ValueError IntPtr
Warning IntPtr
ZeroDivisionError IntPtr

Public Methods

Method Description
Clear ( ) : void

Clear Method

Clear any exception that has been set in the Python runtime.

ErrorOccurred ( ) : bool

ErrorOccurred Method

Returns true if an exception occurred in the Python runtime. This is a wrapper for the Python PyErr_Occurred call.

ExceptionMatches ( IntPtr ob ) : bool

ExceptionMatches Method

Returns true if the current Python exception matches the given Python object. This is a wrapper for PyErr_ExceptionMatches.

ExceptionMatches ( IntPtr exc, IntPtr ob ) : bool

ExceptionMatches Method

Returns true if the given Python exception matches the given Python object. This is a wrapper for PyErr_GivenExceptionMatches.

SetError ( Exception e ) : void

SetError Method

Sets the current Python exception given a CLR exception object. The CLR exception instance is wrapped as a Python object, allowing it to be handled naturally from Python.

SetError ( IntPtr ob, IntPtr value ) : void

SetError Method

Sets the current Python exception given a Python object. This is a wrapper for the Python PyErr_SetObject call.

SetError ( IntPtr ob, string value ) : void

SetError Method

Sets the current Python exception given a native string. This is a wrapper for the Python PyErr_SetString call.

deprecation ( string message ) : void
deprecation ( string message, int stacklevel ) : void
warn ( string message, IntPtr exception ) : void
warn ( string message, IntPtr exception, int stacklevel ) : void

Alias for Python's warnings.warn() function.

Private Methods

Method Description
ErrorCheck ( IntPtr pointer ) : void

Shortcut for (pointer == NULL) -> throw PythonException

ErrorOccurredCheck ( IntPtr pointer ) : void

Shortcut for (pointer == NULL or ErrorOccurred()) -> throw PythonException

Exceptions ( ) : System
Initialize ( ) : void
RaiseTypeError ( string message ) : IntPtr
SetArgsAndCause ( IntPtr ob ) : void

Set the 'args' slot on a python exception object that wraps a CLR exception. This is needed for pickling CLR exceptions as BaseException_reduce will only check the slots, bypassing the __getattr__ implementation, and thus dereferencing a NULL pointer.

Shutdown ( ) : void

Method Details

Clear() public static method

Clear Method
Clear any exception that has been set in the Python runtime.
public static Clear ( ) : void
return void

ErrorOccurred() public static method

ErrorOccurred Method
Returns true if an exception occurred in the Python runtime. This is a wrapper for the Python PyErr_Occurred call.
public static ErrorOccurred ( ) : bool
return bool

ExceptionMatches() public static method

ExceptionMatches Method
Returns true if the current Python exception matches the given Python object. This is a wrapper for PyErr_ExceptionMatches.
public static ExceptionMatches ( IntPtr ob ) : bool
ob System.IntPtr
return bool

ExceptionMatches() public static method

ExceptionMatches Method
Returns true if the given Python exception matches the given Python object. This is a wrapper for PyErr_GivenExceptionMatches.
public static ExceptionMatches ( IntPtr exc, IntPtr ob ) : bool
exc System.IntPtr
ob System.IntPtr
return bool

SetError() public static method

SetError Method
Sets the current Python exception given a CLR exception object. The CLR exception instance is wrapped as a Python object, allowing it to be handled naturally from Python.
public static SetError ( Exception e ) : void
e System.Exception
return void

SetError() public static method

SetError Method
Sets the current Python exception given a Python object. This is a wrapper for the Python PyErr_SetObject call.
public static SetError ( IntPtr ob, IntPtr value ) : void
ob System.IntPtr
value System.IntPtr
return void

SetError() public static method

SetError Method
Sets the current Python exception given a native string. This is a wrapper for the Python PyErr_SetString call.
public static SetError ( IntPtr ob, string value ) : void
ob System.IntPtr
value string
return void

deprecation() public static method

public static deprecation ( string message ) : void
message string
return void

deprecation() public static method

public static deprecation ( string message, int stacklevel ) : void
message string
stacklevel int
return void

warn() public static method

public static warn ( string message, IntPtr exception ) : void
message string
exception IntPtr
return void

warn() public static method

Alias for Python's warnings.warn() function.
public static warn ( string message, IntPtr exception, int stacklevel ) : void
message string
exception IntPtr
stacklevel int
return void

Property Details

ArithmeticError public static property

public static IntPtr,System ArithmeticError
return System.IntPtr

AssertionError public static property

public static IntPtr,System AssertionError
return System.IntPtr

AttributeError public static property

public static IntPtr,System AttributeError
return System.IntPtr

BaseException public static property

public static IntPtr,System BaseException
return System.IntPtr

DeprecationWarning public static property

public static IntPtr,System DeprecationWarning
return System.IntPtr

EOFError public static property

public static IntPtr,System EOFError
return System.IntPtr

EnvironmentError public static property

public static IntPtr,System EnvironmentError
return System.IntPtr

Exception public static property

public static IntPtr,System Exception
return System.IntPtr

FloatingPointError public static property

public static IntPtr,System FloatingPointError
return System.IntPtr

FutureWarning public static property

public static IntPtr,System FutureWarning
return System.IntPtr

GeneratorExit public static property

public static IntPtr,System GeneratorExit
return System.IntPtr

IOError public static property

public static IntPtr,System IOError
return System.IntPtr

ImportError public static property

public static IntPtr,System ImportError
return System.IntPtr

ImportWarning public static property

public static IntPtr,System ImportWarning
return System.IntPtr

IndentationError public static property

public static IntPtr,System IndentationError
return System.IntPtr

IndexError public static property

public static IntPtr,System IndexError
return System.IntPtr

KeyError public static property

public static IntPtr,System KeyError
return System.IntPtr

KeyboardInterrupt public static property

public static IntPtr,System KeyboardInterrupt
return System.IntPtr

LookupError public static property

public static IntPtr,System LookupError
return System.IntPtr

MemoryError public static property

public static IntPtr,System MemoryError
return System.IntPtr

NameError public static property

public static IntPtr,System NameError
return System.IntPtr

NotImplementedError public static property

public static IntPtr,System NotImplementedError
return System.IntPtr

OSError public static property

public static IntPtr,System OSError
return System.IntPtr

OverflowError public static property

public static IntPtr,System OverflowError
return System.IntPtr

PendingDeprecationWarning public static property

public static IntPtr,System PendingDeprecationWarning
return System.IntPtr

ReferenceError public static property

public static IntPtr,System ReferenceError
return System.IntPtr

RuntimeError public static property

public static IntPtr,System RuntimeError
return System.IntPtr

RuntimeWarning public static property

public static IntPtr,System RuntimeWarning
return System.IntPtr

StandardError public static property

public static IntPtr,System StandardError
return System.IntPtr

StopIteration public static property

public static IntPtr,System StopIteration
return System.IntPtr

SyntaxError public static property

public static IntPtr SyntaxError
return IntPtr

SyntaxWarning public static property

public static IntPtr SyntaxWarning
return IntPtr

SystemError public static property

public static IntPtr SystemError
return IntPtr

SystemExit public static property

public static IntPtr SystemExit
return IntPtr

TabError public static property

public static IntPtr TabError
return IntPtr

TypeError public static property

public static IntPtr TypeError
return IntPtr

UnboundLocalError public static property

public static IntPtr UnboundLocalError
return IntPtr

UnicodeDecodeError public static property

public static IntPtr UnicodeDecodeError
return IntPtr

UnicodeEncodeError public static property

public static IntPtr UnicodeEncodeError
return IntPtr

UnicodeError public static property

public static IntPtr UnicodeError
return IntPtr

UnicodeTranslateError public static property

public static IntPtr UnicodeTranslateError
return IntPtr

UnicodeWarning public static property

public static IntPtr UnicodeWarning
return IntPtr

UserWarning public static property

public static IntPtr UserWarning
return IntPtr

ValueError public static property

public static IntPtr ValueError
return IntPtr

Warning public static property

public static IntPtr Warning
return IntPtr

ZeroDivisionError public static property

public static IntPtr ZeroDivisionError
return IntPtr