[][src]Struct pyo3::PyErr

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]

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::<exceptions::TypeError, _>("Error message"));

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

Creates a new PyErr of type T.

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.

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

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.

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

Print a standard traceback to sys.stderr.

Print a standard traceback to sys.stderr.

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.

Return true if the current exception is instance of T

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

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

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

Trait Implementations

impl ToPyObject for PyErr
[src]

impl IntoPyObject for PyErr
[src]

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

impl From<PyDowncastError> for PyErr
[src]

Converts PyDowncastError to Python TypeError.

impl From<PyErr> for Error
[src]

Convert PyErr to io::Error

impl From<Error> for PyErr
[src]

Create OSError from io::Error

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

impl From<ParseIntError> for PyErr
[src]

impl From<ParseFloatError> for PyErr
[src]

impl From<ParseError> for PyErr
[src]

impl From<ParseBoolError> for PyErr
[src]

impl From<IntoStringError> for PyErr
[src]

impl From<NulError> for PyErr
[src]

impl From<Utf8Error> for PyErr
[src]

impl From<FromUtf8Error> for PyErr
[src]

impl From<FromUtf16Error> for PyErr
[src]

impl From<DecodeUtf16Error> for PyErr
[src]

impl From<AddrParseError> for PyErr
[src]

impl From<BaseException> for PyErr
[src]

impl From<Exception> for PyErr
[src]

impl From<StopAsyncIteration> for PyErr
[src]

impl From<StopIteration> for PyErr
[src]

impl From<GeneratorExit> for PyErr
[src]

impl From<ArithmeticError> for PyErr
[src]

impl From<LookupError> for PyErr
[src]

impl From<AssertionError> for PyErr
[src]

impl From<AttributeError> for PyErr
[src]

impl From<BufferError> for PyErr
[src]

impl From<EOFError> for PyErr
[src]

impl From<FloatingPointError> for PyErr
[src]

impl From<OSError> for PyErr
[src]

impl From<ImportError> for PyErr
[src]

impl From<IndexError> for PyErr
[src]

impl From<KeyError> for PyErr
[src]

impl From<KeyboardInterrupt> for PyErr
[src]

impl From<MemoryError> for PyErr
[src]

impl From<NameError> for PyErr
[src]

impl From<OverflowError> for PyErr
[src]

impl From<RuntimeError> for PyErr
[src]

impl From<RecursionError> for PyErr
[src]

impl From<NotImplementedError> for PyErr
[src]

impl From<SyntaxError> for PyErr
[src]

impl From<ReferenceError> for PyErr
[src]

impl From<SystemError> for PyErr
[src]

impl From<SystemExit> for PyErr
[src]

impl From<TypeError> for PyErr
[src]

impl From<UnboundLocalError> for PyErr
[src]

impl From<UnicodeError> for PyErr
[src]

impl From<UnicodeDecodeError> for PyErr
[src]

impl From<UnicodeEncodeError> for PyErr
[src]

impl From<UnicodeTranslateError> for PyErr
[src]

impl From<ValueError> for PyErr
[src]

impl From<ZeroDivisionError> for PyErr
[src]

impl From<BlockingIOError> for PyErr
[src]

impl From<BrokenPipeError> for PyErr
[src]

impl From<ChildProcessError> for PyErr
[src]

impl From<ConnectionError> for PyErr
[src]

impl From<ConnectionAbortedError> for PyErr
[src]

impl From<ConnectionRefusedError> for PyErr
[src]

impl From<ConnectionResetError> for PyErr
[src]

impl From<FileExistsError> for PyErr
[src]

impl From<FileNotFoundError> for PyErr
[src]

impl From<InterruptedError> for PyErr
[src]

impl From<IsADirectoryError> for PyErr
[src]

impl From<NotADirectoryError> for PyErr
[src]

impl From<PermissionError> for PyErr
[src]

impl From<ProcessLookupError> for PyErr
[src]

impl From<TimeoutError> for PyErr
[src]

impl From<EnvironmentError> for PyErr
[src]

impl From<IOError> for PyErr
[src]

impl From<CancelledError> for PyErr
[src]

impl From<InvalidStateError> for PyErr
[src]

impl From<TimeoutError> for PyErr
[src]

impl From<IncompleteReadError> for PyErr
[src]

impl From<LimitOverrunError> for PyErr
[src]

impl From<QueueEmpty> for PyErr
[src]

impl From<QueueFull> for PyErr
[src]

impl From<herror> for PyErr
[src]

impl From<gaierror> for PyErr
[src]

impl From<timeout> for PyErr
[src]

impl<T> Into<Result<T, PyErr>> for PyErr
[src]

Convert PyErr to PyResult<T>

impl Debug for PyErr
[src]

Auto Trait Implementations

impl !Send for PyErr

impl !Sync for PyErr

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]