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