1 | use crate::type_info::*; |
2 | use std::fmt; |
3 | |
4 | /// Definition of a Python execption. |
5 | #[derive (Debug, Clone, PartialEq)] |
6 | pub struct ErrorDef { |
7 | pub name: &'static str, |
8 | pub base: &'static str, |
9 | } |
10 | |
11 | impl From<&PyErrorInfo> for ErrorDef { |
12 | fn from(info: &PyErrorInfo) -> Self { |
13 | Self { |
14 | name: info.name, |
15 | base: (info.base)(), |
16 | } |
17 | } |
18 | } |
19 | |
20 | impl fmt::Display for ErrorDef { |
21 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
22 | writeln!(f, "class {}( {}): ..." , self.name, self.base) |
23 | } |
24 | } |
25 | |