Change PyBorrowError and PyBorrowMutError to inherit RuntimeError

This commit is contained in:
kngwyu 2020-03-18 18:12:50 +09:00
parent 25b594cd47
commit e9b15b83ff
1 changed files with 6 additions and 2 deletions

View File

@ -662,6 +662,8 @@ impl BorrowFlag {
} }
/// An error returned by [`PyCell::try_borrow`](struct.PyCell.html#method.try_borrow). /// An error returned by [`PyCell::try_borrow`](struct.PyCell.html#method.try_borrow).
///
/// In Python, you can catch this error by `except RuntimeError`.
pub struct PyBorrowError { pub struct PyBorrowError {
_private: (), _private: (),
} }
@ -679,6 +681,8 @@ impl fmt::Display for PyBorrowError {
} }
/// An error returned by [`PyCell::try_borrow_mut`](struct.PyCell.html#method.try_borrow_mut). /// An error returned by [`PyCell::try_borrow_mut`](struct.PyCell.html#method.try_borrow_mut).
///
/// In Python, you can catch this error by `except RuntimeError`.
pub struct PyBorrowMutError { pub struct PyBorrowMutError {
_private: (), _private: (),
} }
@ -695,5 +699,5 @@ impl fmt::Display for PyBorrowMutError {
} }
} }
pyo3_exception!(PyBorrowError, crate::exceptions::Exception); pyo3_exception!(PyBorrowError, crate::exceptions::RuntimeError);
pyo3_exception!(PyBorrowMutError, crate::exceptions::Exception); pyo3_exception!(PyBorrowMutError, crate::exceptions::RuntimeError);