Struct pyo3::PyErr [] [src]

pub struct PyErr {
    pub ptype: Py<PyType>,
    pub pvalue: PyErrValue,
    pub ptraceback: Option<PyObject>,
}

Represents a Python exception that was raised.

Fields

The type of the exception. This should be either a PyClass or a PyType.

The value of the exception.

This can be either an instance of PyObject, a tuple of arguments to be passed to ptype's constructor, or a single argument to be passed to ptype's constructor. Call PyErr::instance() to get the exception instance in all cases.

The PyTraceBack object associated with the error.

Methods

impl PyErr
[src]

[src]

Creates a new PyErr of type T.

value can be: * NoArgs: the exception instance will be created using python T() * a tuple: the exception instance will be created using python T(*tuple) * any other value: the exception instance will be created using python T(value)

Panics if T is not a python class derived from BaseException.

Example: return Err(PyErr::new::<exc::TypeError, _>("Error message"));

[src]

Construct a new error, with the usual lazy initialization of Python exceptions. exc is the exception type; usually one of the standard exceptions like exc::RuntimeError. args is the a tuple of arguments to pass to the exception constructor.

[src]

Creates a new PyErr of type T.

[src]

Creates a new PyErr.

obj must be an Python exception instance, the PyErr will use that instance. If obj is a Python exception type object, the PyErr will (lazily) create a new instance of that type. Otherwise, a TypeError is created instead.

[src]

Gets whether an error is present in the Python interpreter's global state.

[src]

Retrieves the current error from the Python interpreter's global state. The error is cleared from the Python interpreter. If no error is set, returns a SystemError.

[src]

Creates a new exception type with the given name, which must be of the form <module>.<ExceptionName>, as required by PyErr_NewException.

base can be an existing exception type to subclass, or a tuple of classes dict specifies an optional dictionary of class variables and methods

[src]

Print a standard traceback to sys.stderr.

[src]

Print a standard traceback to sys.stderr.

[src]

Return true if the current exception matches the exception in exc. If exc is a class object, this also returns true when self is an instance of a subclass. If exc is a tuple, all exceptions in the tuple (and recursively in subtuples) are searched for a match.

[src]

Return true if the current exception is instance of T

[src]

Normalizes the error. This ensures that the exception value is an instance of the exception type.

[src]

Writes the error back to the Python interpreter's global state. This is the opposite of PyErr::fetch().

[src]

Issue a warning message. May return a PyErr if warnings-as-errors is enabled.

[src]

Trait Implementations

impl Debug for PyErr
[src]

[src]

Formats the value using the given formatter.

impl IntoPyObject for PyErr
[src]

[src]

Converts self into a Python object. (Consumes self)

impl ToPyObject for PyErr
[src]

[src]

Converts self into a Python object.

impl<'a> IntoPyObject for &'a PyErr
[src]

[src]

Converts self into a Python object. (Consumes self)

impl From<PyDowncastError> for PyErr
[src]

Converts PyDowncastError to Python TypeError.

[src]

Performs the conversion.

impl<T> Into<PyResult<T>> for PyErr
[src]

Convert PyErr to PyResult<T>

[src]

Performs the conversion.

impl From<Error> for PyErr
[src]

Create OSError from io::Error

[src]

Performs the conversion.

impl<W: 'static + Send + Debug> From<IntoInnerError<W>> for PyErr
[src]

[src]

Performs the conversion.

impl From<ParseIntError> for PyErr
[src]

[src]

Performs the conversion.

impl From<ParseFloatError> for PyErr
[src]

[src]

Performs the conversion.

impl From<ParseError> for PyErr
[src]

[src]

Performs the conversion.

impl From<ParseBoolError> for PyErr
[src]

[src]

Performs the conversion.

impl From<IntoStringError> for PyErr
[src]

[src]

Performs the conversion.

impl From<NulError> for PyErr
[src]

[src]

Performs the conversion.

impl From<Utf8Error> for PyErr
[src]

[src]

Performs the conversion.

impl From<FromUtf8Error> for PyErr
[src]

[src]

Performs the conversion.

impl From<FromUtf16Error> for PyErr
[src]

[src]

Performs the conversion.

impl From<DecodeUtf16Error> for PyErr
[src]

[src]

Performs the conversion.

impl From<AddrParseError> for PyErr
[src]

[src]

Performs the conversion.

impl From<CancelledError> for PyErr
[src]

[src]

Performs the conversion.

impl From<InvalidStateError> for PyErr
[src]

[src]

Performs the conversion.

impl From<TimeoutError> for PyErr
[src]

[src]

Performs the conversion.

impl From<IncompleteReadError> for PyErr
[src]

[src]

Performs the conversion.

impl From<LimitOverrunError> for PyErr
[src]

[src]

Performs the conversion.

impl From<QueueEmpty> for PyErr
[src]

[src]

Performs the conversion.

impl From<QueueFull> for PyErr
[src]

[src]

Performs the conversion.

impl From<herror> for PyErr
[src]

[src]

Performs the conversion.

impl From<gaierror> for PyErr
[src]

[src]

Performs the conversion.

impl From<timeout> for PyErr
[src]

[src]

Performs the conversion.

impl From<BaseException> for PyErr
[src]

[src]

Performs the conversion.

impl From<Exception> for PyErr
[src]

[src]

Performs the conversion.

impl From<StopAsyncIteration> for PyErr
[src]

[src]

Performs the conversion.

impl From<StopIteration> for PyErr
[src]

[src]

Performs the conversion.

impl From<GeneratorExit> for PyErr
[src]

[src]

Performs the conversion.

impl From<ArithmeticError> for PyErr
[src]

[src]

Performs the conversion.

impl From<LookupError> for PyErr
[src]

[src]

Performs the conversion.

impl From<AssertionError> for PyErr
[src]

[src]

Performs the conversion.

impl From<AttributeError> for PyErr
[src]

[src]

Performs the conversion.

impl From<BufferError> for PyErr
[src]

[src]

Performs the conversion.

impl From<EOFError> for PyErr
[src]

[src]

Performs the conversion.

impl From<FloatingPointError> for PyErr
[src]

[src]

Performs the conversion.

impl From<OSError> for PyErr
[src]

[src]

Performs the conversion.

impl From<ImportError> for PyErr
[src]

[src]

Performs the conversion.

impl From<IndexError> for PyErr
[src]

[src]

Performs the conversion.

impl From<KeyError> for PyErr
[src]

[src]

Performs the conversion.

impl From<KeyboardInterrupt> for PyErr
[src]

[src]

Performs the conversion.

impl From<MemoryError> for PyErr
[src]

[src]

Performs the conversion.

impl From<NameError> for PyErr
[src]

[src]

Performs the conversion.

impl From<OverflowError> for PyErr
[src]

[src]

Performs the conversion.

impl From<RuntimeError> for PyErr
[src]

[src]

Performs the conversion.

impl From<RecursionError> for PyErr
[src]

[src]

Performs the conversion.

impl From<NotImplementedError> for PyErr
[src]

[src]

Performs the conversion.

impl From<SyntaxError> for PyErr
[src]

[src]

Performs the conversion.

impl From<ReferenceError> for PyErr
[src]

[src]

Performs the conversion.

impl From<SystemError> for PyErr
[src]

[src]

Performs the conversion.

impl From<SystemExit> for PyErr
[src]

[src]

Performs the conversion.

impl From<TypeError> for PyErr
[src]

[src]

Performs the conversion.

impl From<UnboundLocalError> for PyErr
[src]

[src]

Performs the conversion.

impl From<UnicodeError> for PyErr
[src]

[src]

Performs the conversion.

impl From<UnicodeDecodeError> for PyErr
[src]

[src]

Performs the conversion.

impl From<UnicodeEncodeError> for PyErr
[src]

[src]

Performs the conversion.

impl From<UnicodeTranslateError> for PyErr
[src]

[src]

Performs the conversion.

impl From<ValueError> for PyErr
[src]

[src]

Performs the conversion.

impl From<ZeroDivisionError> for PyErr
[src]

[src]

Performs the conversion.

impl From<BlockingIOError> for PyErr
[src]

[src]

Performs the conversion.

impl From<BrokenPipeError> for PyErr
[src]

[src]

Performs the conversion.

impl From<ChildProcessError> for PyErr
[src]

[src]

Performs the conversion.

impl From<ConnectionError> for PyErr
[src]

[src]

Performs the conversion.

impl From<ConnectionAbortedError> for PyErr
[src]

[src]

Performs the conversion.

impl From<ConnectionRefusedError> for PyErr
[src]

[src]

Performs the conversion.

impl From<ConnectionResetError> for PyErr
[src]

[src]

Performs the conversion.

impl From<FileExistsError> for PyErr
[src]

[src]

Performs the conversion.

impl From<FileNotFoundError> for PyErr
[src]

[src]

Performs the conversion.

impl From<InterruptedError> for PyErr
[src]

[src]

Performs the conversion.

impl From<IsADirectoryError> for PyErr
[src]

[src]

Performs the conversion.

impl From<NotADirectoryError> for PyErr
[src]

[src]

Performs the conversion.

impl From<PermissionError> for PyErr
[src]

[src]

Performs the conversion.

impl From<ProcessLookupError> for PyErr
[src]

[src]

Performs the conversion.

impl From<TimeoutError> for PyErr
[src]

[src]

Performs the conversion.

impl From<EnvironmentError> for PyErr
[src]

[src]

Performs the conversion.

impl From<IOError> for PyErr
[src]

[src]

Performs the conversion.