pub struct PyErr { /* private fields */ }
Expand description
Represents a Python exception.
Python exceptions can be raised in a “lazy” fashion, where the full Python object for the exception is not created until needed. The process of creating the full object is known as “normalization”. An exception which has not yet been created is known as “unnormalized”.
This struct builds upon that design, supporting all lazily-created Python exceptions and also supporting exceptions lazily-created from Rust.
Implementations
sourceimpl PyErr
impl PyErr
sourcepub fn new<T, A>(args: A) -> PyErr where
T: PyTypeObject,
A: PyErrArguments + Send + Sync + 'static,
pub fn new<T, A>(args: A) -> PyErr where
T: PyTypeObject,
A: PyErrArguments + Send + Sync + 'static,
Creates a new PyErr of type T
.
args
can be:
- a tuple: the exception instance will be created using the equivalent to the Python
expression
T(*tuple)
- any other value: the exception instance will be created using the equivalent to the Python
expression
T(value)
This error will be stored in an unnormalized state. This avoids the need for the Python GIL
to be held, but requires args
to be Send
and Sync
. If args
is not Send
or Sync
,
consider using PyErr::from_value
instead.
If an error occurs during normalization (for example if T
is not a Python type which
extends from BaseException
), then a different error may be produced during normalization.
Example
return Err(PyErr::new::<exceptions::PyTypeError, _>("Error message"));
In most cases, you can use a concrete exception’s constructor instead, which is equivalent:
return Err(exceptions::PyTypeError::new_err("Error message"));
sourcepub fn from_type<A>(ty: &PyType, args: A) -> PyErr where
A: PyErrArguments + Send + Sync + 'static,
pub fn from_type<A>(ty: &PyType, args: A) -> PyErr where
A: PyErrArguments + Send + Sync + 'static,
Constructs a new PyErr from the given Python type and arguments.
ty
is the exception type; usually one of the standard exceptions
like exceptions::PyRuntimeError
.
args
is either a tuple or a single value, with the same meaning as in PyErr::new
.
If an error occurs during normalization (for example if T
is not a Python type which
extends from BaseException
), then a different error may be produced during normalization.
This error will be stored in an unnormalized state.
sourcepub fn from_value(obj: &PyAny) -> PyErr
pub fn from_value(obj: &PyAny) -> PyErr
Creates a new PyErr.
If obj
is a Python exception object, the PyErr will contain that object. The error will be
in a normalized state.
If obj
is a Python exception type object, this is equivalent to PyErr::from_type(obj, ())
.
Otherwise, a TypeError
is created.
Examples
use pyo3::{exceptions::PyTypeError, types::PyType, IntoPy, PyErr, Python};
Python::with_gil(|py| {
// Case #1: Exception object
let err = PyErr::from_value(PyTypeError::new_err("some type error").value(py));
assert_eq!(err.to_string(), "TypeError: some type error");
// Case #2: Exception type
let err = PyErr::from_value(PyType::new::<PyTypeError>(py));
assert_eq!(err.to_string(), "TypeError: ");
// Case #3: Invalid exception value
let err = PyErr::from_value("foo".into_py(py).as_ref(py));
assert_eq!(
err.to_string(),
"TypeError: exceptions must derive from BaseException"
);
});
sourcepub fn get_type<'py>(&'py self, py: Python<'py>) -> &'py PyType
pub fn get_type<'py>(&'py self, py: Python<'py>) -> &'py PyType
Returns the type of this exception.
The object will be normalized first if needed.
Examples
use pyo3::{exceptions::PyTypeError, types::PyType, PyErr, Python};
Python::with_gil(|py| {
let err: PyErr = PyTypeError::new_err(("some type error",));
assert!(err.get_type(py).is(PyType::new::<PyTypeError>(py)));
});
sourcepub fn value<'py>(&'py self, py: Python<'py>) -> &'py PyBaseException
pub fn value<'py>(&'py self, py: Python<'py>) -> &'py PyBaseException
Returns the value of this exception.
The object will be normalized first if needed.
Examples
use pyo3::{exceptions::PyTypeError, PyErr, Python};
Python::with_gil(|py| {
let err: PyErr = PyTypeError::new_err(("some type error",));
assert!(err.is_instance_of::<PyTypeError>(py));
assert_eq!(err.value(py).to_string(), "some type error");
});
sourcepub fn into_value(self, py: Python<'_>) -> Py<PyBaseException>
pub fn into_value(self, py: Python<'_>) -> Py<PyBaseException>
Consumes self to take ownership of the exception value contained in this error.
sourcepub fn traceback<'py>(&'py self, py: Python<'py>) -> Option<&'py PyTraceback>
pub fn traceback<'py>(&'py self, py: Python<'py>) -> Option<&'py PyTraceback>
Returns the traceback of this exception object.
The object will be normalized first if needed.
Examples
use pyo3::{exceptions::PyTypeError, Python};
Python::with_gil(|py| {
let err = PyTypeError::new_err(("some type error",));
assert!(err.traceback(py).is_none());
});
sourcepub fn occurred(_: Python<'_>) -> bool
pub fn occurred(_: Python<'_>) -> bool
Gets whether an error is present in the Python interpreter’s global state.
sourcepub fn take(py: Python<'_>) -> Option<PyErr>
pub fn take(py: Python<'_>) -> Option<PyErr>
Takes the current error from the Python interpreter’s global state and clears the global
state. If no error is set, returns None
.
If the error is a PanicException
(which would have originated from a panic in a pyo3
callback) then this function will resume the panic.
Use this function when it is not known if an error should be present. If the error is
expected to have been set, for example from PyErr::occurred
or by an error return value
from a C FFI function, use PyErr::fetch
.
sourcepub fn fetch(py: Python<'_>) -> PyErr
pub fn fetch(py: Python<'_>) -> PyErr
Equivalent to PyErr::take, but when no error is set:
- Panics in debug mode.
- Returns a
SystemError
in release mode.
This behavior is consistent with Python’s internal handling of what happens when a C return value indicates an error occurred but the global error state is empty. (A lack of exception should be treated as a bug in the code which returned an error code but did not set an exception.)
Use this function when the error is expected to have been set, for example from PyErr::occurred or by an error return value from a C FFI function.
sourcepub fn new_type(
py: Python<'_>,
name: &str,
doc: Option<&str>,
base: Option<&PyType>,
dict: Option<PyObject>
) -> PyResult<Py<PyType>>
pub fn new_type(
py: Python<'_>,
name: &str,
doc: Option<&str>,
base: Option<&PyType>,
dict: Option<PyObject>
) -> PyResult<Py<PyType>>
Creates a new exception type with the given name and docstring.
base
can be an existing exception type to subclass, or a tuple of classes.dict
specifies an optional dictionary of class variables and methods.doc
will be the docstring seen by python users.
Errors
This function returns an error if name
is not of the form <module>.<ExceptionName>
.
Panics
This function will panic if name
or doc
cannot be converted to CString
s.
sourcepub fn print_and_set_sys_last_vars(&self, py: Python<'_>)
pub fn print_and_set_sys_last_vars(&self, py: Python<'_>)
Prints a standard traceback to sys.stderr
, and sets
sys.last_{type,value,traceback}
attributes to this exception’s data.
sourcepub fn matches<T>(&self, py: Python<'_>, exc: T) -> bool where
T: ToBorrowedObject,
pub fn matches<T>(&self, py: Python<'_>, exc: T) -> bool where
T: ToBorrowedObject,
Returns 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.
sourcepub fn is_instance(&self, py: Python<'_>, typ: &PyType) -> bool
pub fn is_instance(&self, py: Python<'_>, typ: &PyType) -> bool
Returns true if the current exception is instance of T
.
sourcepub fn is_instance_of<T>(&self, py: Python<'_>) -> bool where
T: PyTypeObject,
pub fn is_instance_of<T>(&self, py: Python<'_>) -> bool where
T: PyTypeObject,
Returns true if the current exception is instance of T
.
sourcepub fn restore(self, py: Python<'_>)
pub fn restore(self, py: Python<'_>)
Writes the error back to the Python interpreter’s global state.
This is the opposite of PyErr::fetch()
.
sourcepub fn warn(
py: Python<'_>,
category: &PyAny,
message: &str,
stacklevel: i32
) -> PyResult<()>
pub fn warn(
py: Python<'_>,
category: &PyAny,
message: &str,
stacklevel: i32
) -> PyResult<()>
Issues a warning message.
May return a PyErr
if warnings-as-errors is enabled.
sourcepub fn clone_ref(&self, py: Python<'_>) -> PyErr
pub fn clone_ref(&self, py: Python<'_>) -> PyErr
Clone the PyErr. This requires the GIL, which is why PyErr does not implement Clone.
Examples
use pyo3::{exceptions::PyTypeError, PyErr, Python};
Python::with_gil(|py| {
let err: PyErr = PyTypeError::new_err(("some type error",));
let err_clone = err.clone_ref(py);
assert!(err.get_type(py).is(err_clone.get_type(py)));
assert!(err.value(py).is(err_clone.value(py)));
match err.traceback(py) {
None => assert!(err_clone.traceback(py).is_none()),
Some(tb) => assert!(err_clone.traceback(py).unwrap().is(tb)),
}
});
sourcepub fn cause(&self, py: Python<'_>) -> Option<PyErr>
pub fn cause(&self, py: Python<'_>) -> Option<PyErr>
Return the cause (either an exception instance, or None, set by raise ... from ...
)
associated with the exception, as accessible from Python through __cause__
.
sourcepub fn set_cause(&self, py: Python<'_>, cause: Option<Self>)
pub fn set_cause(&self, py: Python<'_>, cause: Option<Self>)
Set the cause associated with the exception, pass None
to clear it.
sourcepub fn ptype<'py>(&'py self, py: Python<'py>) -> &'py PyType
👎 Deprecated since 0.16.0: Use err.get_type(py) instead of err.ptype(py)
pub fn ptype<'py>(&'py self, py: Python<'py>) -> &'py PyType
Use err.get_type(py) instead of err.ptype(py)
Deprecated name for PyErr::get_type
.
sourcepub fn pvalue<'py>(&'py self, py: Python<'py>) -> &'py PyBaseException
👎 Deprecated since 0.16.0: Use err.value(py) instead of err.pvalue(py)
pub fn pvalue<'py>(&'py self, py: Python<'py>) -> &'py PyBaseException
Use err.value(py) instead of err.pvalue(py)
Deprecated name for PyErr::value
.
sourcepub fn ptraceback<'py>(&'py self, py: Python<'py>) -> Option<&'py PyTraceback>
👎 Deprecated since 0.16.0: Use err.traceback(py) instead of err.ptraceback(py)
pub fn ptraceback<'py>(&'py self, py: Python<'py>) -> Option<&'py PyTraceback>
Use err.traceback(py) instead of err.ptraceback(py)
Deprecated name for PyErr::traceback
.
sourcepub fn instance<'py>(&'py self, py: Python<'py>) -> &'py PyBaseException
👎 Deprecated since 0.16.0: Use err.value(py) instead of err.instance(py)
pub fn instance<'py>(&'py self, py: Python<'py>) -> &'py PyBaseException
Use err.value(py) instead of err.instance(py)
Deprecated name for PyErr::value
.
sourcepub fn from_instance(value: &PyAny) -> PyErr
👎 Deprecated since 0.16.0: Use err.from_value(py, obj) instead of err.from_instance(py, obj)
pub fn from_instance(value: &PyAny) -> PyErr
Use err.from_value(py, obj) instead of err.from_instance(py, obj)
Deprecated name for PyErr::from_value
.
sourcepub fn into_instance(self, py: Python<'_>) -> Py<PyBaseException>
👎 Deprecated since 0.16.0: Use err.into_value(py) instead of err.into_instance(py)
pub fn into_instance(self, py: Python<'_>) -> Py<PyBaseException>
Use err.into_value(py) instead of err.into_instance(py)
Deprecated name for PyErr::into_value
.
Trait Implementations
sourceimpl Error for PyErr
impl Error for PyErr
1.30.0 · sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
sourcefn backtrace(&self) -> Option<&Backtrace>
fn backtrace(&self) -> Option<&Backtrace>
backtrace
)Returns a stack backtrace, if available, of where this error occurred. Read more
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
sourceimpl From<&'_ CancelledError> for PyErr
impl From<&'_ CancelledError> for PyErr
sourcefn from(err: &CancelledError) -> PyErr
fn from(err: &CancelledError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ IncompleteReadError> for PyErr
impl From<&'_ IncompleteReadError> for PyErr
sourcefn from(err: &IncompleteReadError) -> PyErr
fn from(err: &IncompleteReadError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ InvalidStateError> for PyErr
impl From<&'_ InvalidStateError> for PyErr
sourcefn from(err: &InvalidStateError) -> PyErr
fn from(err: &InvalidStateError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ LimitOverrunError> for PyErr
impl From<&'_ LimitOverrunError> for PyErr
sourcefn from(err: &LimitOverrunError) -> PyErr
fn from(err: &LimitOverrunError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PanicException> for PyErr
impl From<&'_ PanicException> for PyErr
sourcefn from(err: &PanicException) -> PyErr
fn from(err: &PanicException) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyArithmeticError> for PyErr
impl From<&'_ PyArithmeticError> for PyErr
sourcefn from(err: &PyArithmeticError) -> PyErr
fn from(err: &PyArithmeticError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyAssertionError> for PyErr
impl From<&'_ PyAssertionError> for PyErr
sourcefn from(err: &PyAssertionError) -> PyErr
fn from(err: &PyAssertionError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyAttributeError> for PyErr
impl From<&'_ PyAttributeError> for PyErr
sourcefn from(err: &PyAttributeError) -> PyErr
fn from(err: &PyAttributeError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyBaseException> for PyErr
impl From<&'_ PyBaseException> for PyErr
sourcefn from(err: &PyBaseException) -> PyErr
fn from(err: &PyBaseException) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyBlockingIOError> for PyErr
impl From<&'_ PyBlockingIOError> for PyErr
sourcefn from(err: &PyBlockingIOError) -> PyErr
fn from(err: &PyBlockingIOError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyBrokenPipeError> for PyErr
impl From<&'_ PyBrokenPipeError> for PyErr
sourcefn from(err: &PyBrokenPipeError) -> PyErr
fn from(err: &PyBrokenPipeError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyBufferError> for PyErr
impl From<&'_ PyBufferError> for PyErr
sourcefn from(err: &PyBufferError) -> PyErr
fn from(err: &PyBufferError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyChildProcessError> for PyErr
impl From<&'_ PyChildProcessError> for PyErr
sourcefn from(err: &PyChildProcessError) -> PyErr
fn from(err: &PyChildProcessError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyConnectionAbortedError> for PyErr
impl From<&'_ PyConnectionAbortedError> for PyErr
sourcefn from(err: &PyConnectionAbortedError) -> PyErr
fn from(err: &PyConnectionAbortedError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyConnectionError> for PyErr
impl From<&'_ PyConnectionError> for PyErr
sourcefn from(err: &PyConnectionError) -> PyErr
fn from(err: &PyConnectionError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyConnectionRefusedError> for PyErr
impl From<&'_ PyConnectionRefusedError> for PyErr
sourcefn from(err: &PyConnectionRefusedError) -> PyErr
fn from(err: &PyConnectionRefusedError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyConnectionResetError> for PyErr
impl From<&'_ PyConnectionResetError> for PyErr
sourcefn from(err: &PyConnectionResetError) -> PyErr
fn from(err: &PyConnectionResetError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyEOFError> for PyErr
impl From<&'_ PyEOFError> for PyErr
sourcefn from(err: &PyEOFError) -> PyErr
fn from(err: &PyEOFError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyEnvironmentError> for PyErr
impl From<&'_ PyEnvironmentError> for PyErr
sourcefn from(err: &PyEnvironmentError) -> PyErr
fn from(err: &PyEnvironmentError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyException> for PyErr
impl From<&'_ PyException> for PyErr
sourcefn from(err: &PyException) -> PyErr
fn from(err: &PyException) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyFileExistsError> for PyErr
impl From<&'_ PyFileExistsError> for PyErr
sourcefn from(err: &PyFileExistsError) -> PyErr
fn from(err: &PyFileExistsError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyFileNotFoundError> for PyErr
impl From<&'_ PyFileNotFoundError> for PyErr
sourcefn from(err: &PyFileNotFoundError) -> PyErr
fn from(err: &PyFileNotFoundError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyFloatingPointError> for PyErr
impl From<&'_ PyFloatingPointError> for PyErr
sourcefn from(err: &PyFloatingPointError) -> PyErr
fn from(err: &PyFloatingPointError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyGeneratorExit> for PyErr
impl From<&'_ PyGeneratorExit> for PyErr
sourcefn from(err: &PyGeneratorExit) -> PyErr
fn from(err: &PyGeneratorExit) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyImportError> for PyErr
impl From<&'_ PyImportError> for PyErr
sourcefn from(err: &PyImportError) -> PyErr
fn from(err: &PyImportError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyIndexError> for PyErr
impl From<&'_ PyIndexError> for PyErr
sourcefn from(err: &PyIndexError) -> PyErr
fn from(err: &PyIndexError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyInterruptedError> for PyErr
impl From<&'_ PyInterruptedError> for PyErr
sourcefn from(err: &PyInterruptedError) -> PyErr
fn from(err: &PyInterruptedError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyIsADirectoryError> for PyErr
impl From<&'_ PyIsADirectoryError> for PyErr
sourcefn from(err: &PyIsADirectoryError) -> PyErr
fn from(err: &PyIsADirectoryError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyKeyError> for PyErr
impl From<&'_ PyKeyError> for PyErr
sourcefn from(err: &PyKeyError) -> PyErr
fn from(err: &PyKeyError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyKeyboardInterrupt> for PyErr
impl From<&'_ PyKeyboardInterrupt> for PyErr
sourcefn from(err: &PyKeyboardInterrupt) -> PyErr
fn from(err: &PyKeyboardInterrupt) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyLookupError> for PyErr
impl From<&'_ PyLookupError> for PyErr
sourcefn from(err: &PyLookupError) -> PyErr
fn from(err: &PyLookupError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyMemoryError> for PyErr
impl From<&'_ PyMemoryError> for PyErr
sourcefn from(err: &PyMemoryError) -> PyErr
fn from(err: &PyMemoryError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyModuleNotFoundError> for PyErr
impl From<&'_ PyModuleNotFoundError> for PyErr
sourcefn from(err: &PyModuleNotFoundError) -> PyErr
fn from(err: &PyModuleNotFoundError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyNameError> for PyErr
impl From<&'_ PyNameError> for PyErr
sourcefn from(err: &PyNameError) -> PyErr
fn from(err: &PyNameError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyNotADirectoryError> for PyErr
impl From<&'_ PyNotADirectoryError> for PyErr
sourcefn from(err: &PyNotADirectoryError) -> PyErr
fn from(err: &PyNotADirectoryError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyNotImplementedError> for PyErr
impl From<&'_ PyNotImplementedError> for PyErr
sourcefn from(err: &PyNotImplementedError) -> PyErr
fn from(err: &PyNotImplementedError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyOverflowError> for PyErr
impl From<&'_ PyOverflowError> for PyErr
sourcefn from(err: &PyOverflowError) -> PyErr
fn from(err: &PyOverflowError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyPermissionError> for PyErr
impl From<&'_ PyPermissionError> for PyErr
sourcefn from(err: &PyPermissionError) -> PyErr
fn from(err: &PyPermissionError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyProcessLookupError> for PyErr
impl From<&'_ PyProcessLookupError> for PyErr
sourcefn from(err: &PyProcessLookupError) -> PyErr
fn from(err: &PyProcessLookupError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyRecursionError> for PyErr
impl From<&'_ PyRecursionError> for PyErr
sourcefn from(err: &PyRecursionError) -> PyErr
fn from(err: &PyRecursionError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyReferenceError> for PyErr
impl From<&'_ PyReferenceError> for PyErr
sourcefn from(err: &PyReferenceError) -> PyErr
fn from(err: &PyReferenceError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyRuntimeError> for PyErr
impl From<&'_ PyRuntimeError> for PyErr
sourcefn from(err: &PyRuntimeError) -> PyErr
fn from(err: &PyRuntimeError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyStopAsyncIteration> for PyErr
impl From<&'_ PyStopAsyncIteration> for PyErr
sourcefn from(err: &PyStopAsyncIteration) -> PyErr
fn from(err: &PyStopAsyncIteration) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyStopIteration> for PyErr
impl From<&'_ PyStopIteration> for PyErr
sourcefn from(err: &PyStopIteration) -> PyErr
fn from(err: &PyStopIteration) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PySyntaxError> for PyErr
impl From<&'_ PySyntaxError> for PyErr
sourcefn from(err: &PySyntaxError) -> PyErr
fn from(err: &PySyntaxError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PySystemError> for PyErr
impl From<&'_ PySystemError> for PyErr
sourcefn from(err: &PySystemError) -> PyErr
fn from(err: &PySystemError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PySystemExit> for PyErr
impl From<&'_ PySystemExit> for PyErr
sourcefn from(err: &PySystemExit) -> PyErr
fn from(err: &PySystemExit) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyTimeoutError> for PyErr
impl From<&'_ PyTimeoutError> for PyErr
sourcefn from(err: &PyTimeoutError) -> PyErr
fn from(err: &PyTimeoutError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyTypeError> for PyErr
impl From<&'_ PyTypeError> for PyErr
sourcefn from(err: &PyTypeError) -> PyErr
fn from(err: &PyTypeError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyUnboundLocalError> for PyErr
impl From<&'_ PyUnboundLocalError> for PyErr
sourcefn from(err: &PyUnboundLocalError) -> PyErr
fn from(err: &PyUnboundLocalError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyUnicodeDecodeError> for PyErr
impl From<&'_ PyUnicodeDecodeError> for PyErr
sourcefn from(err: &PyUnicodeDecodeError) -> PyErr
fn from(err: &PyUnicodeDecodeError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyUnicodeEncodeError> for PyErr
impl From<&'_ PyUnicodeEncodeError> for PyErr
sourcefn from(err: &PyUnicodeEncodeError) -> PyErr
fn from(err: &PyUnicodeEncodeError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyUnicodeError> for PyErr
impl From<&'_ PyUnicodeError> for PyErr
sourcefn from(err: &PyUnicodeError) -> PyErr
fn from(err: &PyUnicodeError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyUnicodeTranslateError> for PyErr
impl From<&'_ PyUnicodeTranslateError> for PyErr
sourcefn from(err: &PyUnicodeTranslateError) -> PyErr
fn from(err: &PyUnicodeTranslateError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyValueError> for PyErr
impl From<&'_ PyValueError> for PyErr
sourcefn from(err: &PyValueError) -> PyErr
fn from(err: &PyValueError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ PyZeroDivisionError> for PyErr
impl From<&'_ PyZeroDivisionError> for PyErr
sourcefn from(err: &PyZeroDivisionError) -> PyErr
fn from(err: &PyZeroDivisionError) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ QueueEmpty> for PyErr
impl From<&'_ QueueEmpty> for PyErr
sourcefn from(err: &QueueEmpty) -> PyErr
fn from(err: &QueueEmpty) -> PyErr
Converts to this type from the input type.
sourceimpl From<&'_ TimeoutError> for PyErr
impl From<&'_ TimeoutError> for PyErr
sourcefn from(err: &TimeoutError) -> PyErr
fn from(err: &TimeoutError) -> PyErr
Converts to this type from the input type.
sourceimpl From<AddrParseError> for PyErr
impl From<AddrParseError> for PyErr
sourcefn from(err: AddrParseError) -> PyErr
fn from(err: AddrParseError) -> PyErr
Converts to this type from the input type.
sourceimpl From<DecodeUtf16Error> for PyErr
impl From<DecodeUtf16Error> for PyErr
sourcefn from(err: DecodeUtf16Error) -> PyErr
fn from(err: DecodeUtf16Error) -> PyErr
Converts to this type from the input type.
sourceimpl From<FromUtf16Error> for PyErr
impl From<FromUtf16Error> for PyErr
sourcefn from(err: FromUtf16Error) -> PyErr
fn from(err: FromUtf16Error) -> PyErr
Converts to this type from the input type.
sourceimpl From<FromUtf8Error> for PyErr
impl From<FromUtf8Error> for PyErr
sourcefn from(err: FromUtf8Error) -> PyErr
fn from(err: FromUtf8Error) -> PyErr
Converts to this type from the input type.
sourceimpl From<Infallible> for PyErr
impl From<Infallible> for PyErr
sourcefn from(_: Infallible) -> PyErr
fn from(_: Infallible) -> PyErr
Converts to this type from the input type.
sourceimpl<W: 'static + Send + Sync + Debug> From<IntoInnerError<W>> for PyErr
impl<W: 'static + Send + Sync + Debug> From<IntoInnerError<W>> for PyErr
sourcefn from(err: IntoInnerError<W>) -> PyErr
fn from(err: IntoInnerError<W>) -> PyErr
Converts to this type from the input type.
sourceimpl From<IntoStringError> for PyErr
impl From<IntoStringError> for PyErr
sourcefn from(err: IntoStringError) -> PyErr
fn from(err: IntoStringError) -> PyErr
Converts to this type from the input type.
sourceimpl From<ParseBoolError> for PyErr
impl From<ParseBoolError> for PyErr
sourcefn from(err: ParseBoolError) -> PyErr
fn from(err: ParseBoolError) -> PyErr
Converts to this type from the input type.
sourceimpl From<ParseFloatError> for PyErr
impl From<ParseFloatError> for PyErr
sourcefn from(err: ParseFloatError) -> PyErr
fn from(err: ParseFloatError) -> PyErr
Converts to this type from the input type.
sourceimpl From<ParseIntError> for PyErr
impl From<ParseIntError> for PyErr
sourcefn from(err: ParseIntError) -> PyErr
fn from(err: ParseIntError) -> PyErr
Converts to this type from the input type.
sourceimpl From<PyBorrowError> for PyErr
impl From<PyBorrowError> for PyErr
sourcefn from(other: PyBorrowError) -> Self
fn from(other: PyBorrowError) -> Self
Converts to this type from the input type.
sourceimpl From<PyBorrowMutError> for PyErr
impl From<PyBorrowMutError> for PyErr
sourcefn from(other: PyBorrowMutError) -> Self
fn from(other: PyBorrowMutError) -> Self
Converts to this type from the input type.
sourceimpl<'a> From<PyDowncastError<'a>> for PyErr
impl<'a> From<PyDowncastError<'a>> for PyErr
Convert PyDowncastError
to Python TypeError
.
sourcefn from(err: PyDowncastError<'_>) -> PyErr
fn from(err: PyDowncastError<'_>) -> PyErr
Converts to this type from the input type.
sourceimpl From<Report> for PyErr
impl From<Report> for PyErr
Converts eyre::Report
to a PyErr
containing a PyRuntimeError
.
If you want to raise a different Python exception you will have to do so manually. See
PyErr::new
for more information about that.
sourceimpl From<TryFromIntError> for PyErr
impl From<TryFromIntError> for PyErr
sourcefn from(err: TryFromIntError) -> PyErr
fn from(err: TryFromIntError) -> PyErr
Converts to this type from the input type.
sourceimpl From<TryFromSliceError> for PyErr
impl From<TryFromSliceError> for PyErr
sourcefn from(err: TryFromSliceError) -> PyErr
fn from(err: TryFromSliceError) -> PyErr
Converts to this type from the input type.
sourceimpl ToPyObject for PyErr
impl ToPyObject for PyErr
impl Send for PyErr
impl Sync for PyErr
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more