pub struct PyErr { /* private fields */ }Expand description
Represents a Python exception that was raised.
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.
value can be:
- 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)
Note: if value is not Send or Sync, consider using PyErr::from_instance instead.
Panics if T is not a Python class derived from BaseException.
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 error, with the usual lazy initialization of Python exceptions.
exc is the exception type; usually one of the standard exceptions
like exceptions::PyRuntimeError.
args is the a tuple of arguments to pass to the exception constructor.
sourcepub fn from_instance(obj: &PyAny) -> PyErr
pub fn from_instance(obj: &PyAny) -> PyErr
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.
Examples
use pyo3::{exceptions::PyTypeError, types::PyType, IntoPy, PyErr, Python};
Python::with_gil(|py| {
// Case #1: Exception instance
let err = PyErr::from_instance(PyTypeError::new_err("some type error").instance(py));
assert_eq!(err.to_string(), "TypeError: some type error");
// Case #2: Exception type
let err = PyErr::from_instance(PyType::new::<PyTypeError>(py));
assert_eq!(err.to_string(), "TypeError: ");
// Case #3: Invalid exception value
let err = PyErr::from_instance("foo".into_py(py).as_ref(py));
assert_eq!(
err.to_string(),
"TypeError: exceptions must derive from BaseException"
);
});sourcepub fn ptype<'py>(&'py self, py: Python<'py>) -> &'py PyType
pub fn ptype<'py>(&'py self, py: Python<'py>) -> &'py PyType
Get the type of this exception object.
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_eq!(err.ptype(py), PyType::new::<PyTypeError>(py));
});sourcepub fn pvalue<'py>(&'py self, py: Python<'py>) -> &'py PyBaseException
pub fn pvalue<'py>(&'py self, py: Python<'py>) -> &'py PyBaseException
Get the value of this exception object.
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::<PyTypeError>(py));
assert_eq!(err.pvalue(py).to_string(), "some type error");
});sourcepub fn ptraceback<'py>(&'py self, py: Python<'py>) -> Option<&'py PyTraceback>
pub fn ptraceback<'py>(&'py self, py: Python<'py>) -> Option<&'py PyTraceback>
Get the value 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_eq!(err.ptraceback(py), 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
SystemErrorin 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<'p>(
_: Python<'p>,
name: &str,
base: Option<&PyType>,
dict: Option<PyObject>
) -> NonNull<PyTypeObject>
pub fn new_type<'p>(
_: Python<'p>,
name: &str,
base: Option<&PyType>,
dict: Option<PyObject>
) -> NonNull<PyTypeObject>
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
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<T>(&self, py: Python<'_>) -> bool where
T: PyTypeObject,
pub fn is_instance<T>(&self, py: Python<'_>) -> bool where
T: PyTypeObject,
Returns true if the current exception is instance of T.
sourcepub fn instance<'py>(&'py self, py: Python<'py>) -> &'py PyBaseException
pub fn instance<'py>(&'py self, py: Python<'py>) -> &'py PyBaseException
Retrieves the exception instance for this error.
sourcepub fn into_instance(self, py: Python<'_>) -> Py<PyBaseException>
pub fn into_instance(self, py: Python<'_>) -> Py<PyBaseException>
Consumes self to take ownership of the exception instance for this error.
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_eq!(err.ptype(py), err_clone.ptype(py));
assert_eq!(err.pvalue(py), err_clone.pvalue(py));
assert_eq!(err.ptraceback(py), err_clone.ptraceback(py));
});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