1use pyo3::exceptions::*;
2
3#[macro_export]
11macro_rules! create_exception {
12 ($module: expr, $name: ident, $base: ty) => {
13 $crate::create_exception!($module, $name, $base, "");
14 };
15 ($module: expr, $name: ident, $base: ty, $doc: expr) => {
16 ::pyo3::create_exception!($module, $name, $base, $doc);
17
18 impl $crate::PyStubType for $name {
20 fn type_output() -> $crate::TypeInfo {
21 $crate::TypeInfo::builtin(stringify!($name))
22 }
23 }
24
25 $crate::inventory::submit! {
26 $crate::type_info::PyClassInfo {
27 pyclass_name: stringify!($name),
28 struct_id: std::any::TypeId::of::<$name>,
29 getters: &[],
30 setters: &[],
31 module: Some(stringify!($module)),
32 doc: $doc,
33 bases: &[|| <$base as $crate::PyStubType>::type_output()],
34 has_eq: false,
35 has_ord: false,
36 has_hash: false,
37 has_str: false,
38 subclass: true,
39 }
40 }
41 };
42}
43
44macro_rules! impl_exception_stub_type {
46 ($name:ident, $type_name:literal) => {
47 impl crate::PyStubType for $name {
48 fn type_output() -> crate::TypeInfo {
49 crate::TypeInfo::builtin($type_name)
50 }
51 }
52 };
53}
54
55impl_exception_stub_type!(PyArithmeticError, "ArithmeticError");
56impl_exception_stub_type!(PyAssertionError, "AssertionError");
57impl_exception_stub_type!(PyAttributeError, "AttributeError");
58impl_exception_stub_type!(PyBaseException, "BaseException");
59impl_exception_stub_type!(PyBlockingIOError, "BlockingIOError");
60impl_exception_stub_type!(PyBrokenPipeError, "BrokenPipeError");
61impl_exception_stub_type!(PyBufferError, "BufferError");
62impl_exception_stub_type!(PyBytesWarning, "BytesWarning");
63impl_exception_stub_type!(PyChildProcessError, "ChildProcessError");
64impl_exception_stub_type!(PyConnectionAbortedError, "ConnectionAbortedError");
65impl_exception_stub_type!(PyConnectionError, "ConnectionError");
66impl_exception_stub_type!(PyConnectionRefusedError, "ConnectionRefusedError");
67impl_exception_stub_type!(PyConnectionResetError, "ConnectionResetError");
68impl_exception_stub_type!(PyDeprecationWarning, "DeprecationWarning");
69impl_exception_stub_type!(PyEOFError, "EOFError");
70impl_exception_stub_type!(PyEncodingWarning, "EncodingWarning");
71impl_exception_stub_type!(PyEnvironmentError, "EnvironmentError");
72impl_exception_stub_type!(PyException, "Exception");
73impl_exception_stub_type!(PyFileExistsError, "FileExistsError");
74impl_exception_stub_type!(PyFileNotFoundError, "FileNotFoundError");
75impl_exception_stub_type!(PyFloatingPointError, "FloatingPointError");
76impl_exception_stub_type!(PyFutureWarning, "FutureWarning");
77impl_exception_stub_type!(PyGeneratorExit, "GeneratorExit");
78impl_exception_stub_type!(PyIOError, "IOError");
79impl_exception_stub_type!(PyImportError, "ImportError");
80impl_exception_stub_type!(PyImportWarning, "ImportWarning");
81impl_exception_stub_type!(PyIndexError, "IndexError");
82impl_exception_stub_type!(PyInterruptedError, "InterruptedError");
83impl_exception_stub_type!(PyIsADirectoryError, "IsADirectoryError");
84impl_exception_stub_type!(PyKeyError, "KeyError");
85impl_exception_stub_type!(PyKeyboardInterrupt, "KeyboardInterrupt");
86impl_exception_stub_type!(PyLookupError, "LookupError");
87impl_exception_stub_type!(PyMemoryError, "MemoryError");
88impl_exception_stub_type!(PyModuleNotFoundError, "ModuleNotFoundError");
89impl_exception_stub_type!(PyNameError, "NameError");
90impl_exception_stub_type!(PyNotADirectoryError, "NotADirectoryError");
91impl_exception_stub_type!(PyNotImplementedError, "NotImplementedError");
92impl_exception_stub_type!(PyOSError, "OSError");
93impl_exception_stub_type!(PyOverflowError, "OverflowError");
94impl_exception_stub_type!(PyPendingDeprecationWarning, "PendingDeprecationWarning");
95impl_exception_stub_type!(PyPermissionError, "PermissionError");
96impl_exception_stub_type!(PyProcessLookupError, "ProcessLookupError");
97impl_exception_stub_type!(PyRecursionError, "RecursionError");
98impl_exception_stub_type!(PyReferenceError, "ReferenceError");
99impl_exception_stub_type!(PyResourceWarning, "ResourceWarning");
100impl_exception_stub_type!(PyRuntimeError, "RuntimeError");
101impl_exception_stub_type!(PyRuntimeWarning, "RuntimeWarning");
102impl_exception_stub_type!(PyStopAsyncIteration, "StopAsyncIteration");
103impl_exception_stub_type!(PyStopIteration, "StopIteration");
104impl_exception_stub_type!(PySyntaxError, "SyntaxError");
105impl_exception_stub_type!(PySyntaxWarning, "SyntaxWarning");
106impl_exception_stub_type!(PySystemError, "SystemError");
107impl_exception_stub_type!(PySystemExit, "SystemExit");
108impl_exception_stub_type!(PyTimeoutError, "TimeoutError");
109impl_exception_stub_type!(PyTypeError, "TypeError");
110impl_exception_stub_type!(PyUnboundLocalError, "UnboundLocalError");
111impl_exception_stub_type!(PyUnicodeDecodeError, "UnicodeDecodeError");
112impl_exception_stub_type!(PyUnicodeEncodeError, "UnicodeEncodeError");
113impl_exception_stub_type!(PyUnicodeError, "UnicodeError");
114impl_exception_stub_type!(PyUnicodeTranslateError, "UnicodeTranslateError");
115impl_exception_stub_type!(PyUnicodeWarning, "UnicodeWarning");
116impl_exception_stub_type!(PyUserWarning, "UserWarning");
117impl_exception_stub_type!(PyValueError, "ValueError");
118impl_exception_stub_type!(PyWarning, "Warning");
119impl_exception_stub_type!(PyZeroDivisionError, "ZeroDivisionError");