@@ -81,23 +81,23 @@ fn exception_str(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
81
81
82
82
#[ derive( Debug ) ]
83
83
pub struct ExceptionZoo {
84
- pub base_exception_type : PyObjectRef ,
85
- pub exception_type : PyObjectRef ,
86
- pub syntax_error : PyObjectRef ,
87
84
pub assertion_error : PyObjectRef ,
88
85
pub attribute_error : PyObjectRef ,
86
+ pub base_exception_type : PyObjectRef ,
87
+ pub exception_type : PyObjectRef ,
88
+ pub file_not_found_error : PyObjectRef ,
89
+ pub import_error : PyObjectRef ,
89
90
pub index_error : PyObjectRef ,
90
91
pub key_error : PyObjectRef ,
92
+ pub module_not_found_error : PyObjectRef ,
91
93
pub name_error : PyObjectRef ,
92
- pub runtime_error : PyObjectRef ,
93
94
pub not_implemented_error : PyObjectRef ,
95
+ pub permission_error : PyObjectRef ,
96
+ pub runtime_error : PyObjectRef ,
94
97
pub stop_iteration : PyObjectRef ,
98
+ pub syntax_error : PyObjectRef ,
95
99
pub type_error : PyObjectRef ,
96
100
pub value_error : PyObjectRef ,
97
- pub import_error : PyObjectRef ,
98
- pub module_not_found_error : PyObjectRef ,
99
- pub file_not_found_error : PyObjectRef ,
100
- pub permission_error : PyObjectRef ,
101
101
}
102
102
103
103
impl ExceptionZoo {
@@ -106,11 +106,13 @@ impl ExceptionZoo {
106
106
object_type : & PyObjectRef ,
107
107
dict_type : & PyObjectRef ,
108
108
) -> Self {
109
+ // Sorted By Hierarchy then alphabetized.
110
+
109
111
let base_exception_type =
110
112
create_type ( "BaseException" , & type_type, & object_type, & dict_type) ;
111
113
112
114
let exception_type = create_type ( "Exception" , & type_type, & base_exception_type, & dict_type) ;
113
- let syntax_error = create_type ( "SyntaxError" , & type_type , & exception_type , & dict_type ) ;
115
+
114
116
let assertion_error =
115
117
create_type ( "AssertionError" , & type_type, & exception_type, & dict_type) ;
116
118
let attribute_error = create_type (
@@ -119,6 +121,7 @@ impl ExceptionZoo {
119
121
& exception_type. clone ( ) ,
120
122
& dict_type,
121
123
) ;
124
+ let import_error = create_type ( "ImportError" , & type_type, & exception_type, & dict_type) ;
122
125
let index_error = create_type (
123
126
"IndexError" ,
124
127
& type_type,
@@ -128,41 +131,42 @@ impl ExceptionZoo {
128
131
let key_error = create_type ( "KeyError" , & type_type, & exception_type. clone ( ) , & dict_type) ;
129
132
let name_error = create_type ( "NameError" , & type_type, & exception_type. clone ( ) , & dict_type) ;
130
133
let runtime_error = create_type ( "RuntimeError" , & type_type, & exception_type, & dict_type) ;
134
+ let stop_iteration = create_type ( "StopIteration" , & type_type, & exception_type, & dict_type) ;
135
+ let syntax_error = create_type ( "SyntaxError" , & type_type, & exception_type, & dict_type) ;
136
+ let type_error = create_type ( "TypeError" , & type_type, & exception_type, & dict_type) ;
137
+ let value_error = create_type ( "ValueError" , & type_type, & exception_type, & dict_type) ;
138
+
139
+ let file_not_found_error =
140
+ create_type ( "FileNotFoundError" , & type_type, & import_error, & dict_type) ;
141
+ let module_not_found_error =
142
+ create_type ( "ModuleNotFoundError" , & type_type, & import_error, & dict_type) ;
131
143
let not_implemented_error = create_type (
132
144
"NotImplementedError" ,
133
145
& type_type,
134
146
& runtime_error,
135
147
& dict_type,
136
148
) ;
137
- let stop_iteration = create_type ( "StopIteration" , & type_type, & exception_type, & dict_type) ;
138
- let type_error = create_type ( "TypeError" , & type_type, & exception_type, & dict_type) ;
139
- let value_error = create_type ( "ValueError" , & type_type, & exception_type, & dict_type) ;
140
- let import_error = create_type ( "ImportError" , & type_type, & exception_type, & dict_type) ;
141
- let module_not_found_error =
142
- create_type ( "ModuleNotFoundError" , & type_type, & import_error, & dict_type) ;
143
- let file_not_found_error =
144
- create_type ( "FileNotFoundError" , & type_type, & import_error, & dict_type) ;
145
149
let permission_error =
146
150
create_type ( "PermissionError" , & type_type, & import_error, & dict_type) ;
147
151
148
152
ExceptionZoo {
149
- base_exception_type : base_exception_type,
150
- exception_type : exception_type,
151
- syntax_error : syntax_error,
152
153
assertion_error : assertion_error,
153
154
attribute_error : attribute_error,
155
+ base_exception_type : base_exception_type,
156
+ exception_type : exception_type,
157
+ file_not_found_error : file_not_found_error,
158
+ import_error : import_error,
154
159
index_error : index_error,
155
160
key_error : key_error,
161
+ module_not_found_error : module_not_found_error,
156
162
name_error : name_error,
157
- runtime_error : runtime_error,
158
163
not_implemented_error : not_implemented_error,
164
+ permission_error : permission_error,
165
+ runtime_error : runtime_error,
159
166
stop_iteration : stop_iteration,
167
+ syntax_error : syntax_error,
160
168
type_error : type_error,
161
169
value_error : value_error,
162
- import_error : import_error,
163
- module_not_found_error : module_not_found_error,
164
- file_not_found_error : file_not_found_error,
165
- permission_error : permission_error,
166
170
}
167
171
}
168
172
}
0 commit comments