pydefine 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pydefine/__init__.py +84 -0
- pydefine/cli.py +284 -0
- pydefine/core.py +456 -0
- pydefine/i18n.py +344 -0
- pydefine/mapping.py +1037 -0
- pydefine/utils.py +442 -0
- pydefine/version.py +20 -0
- pydefine-1.0.0.dist-info/METADATA +395 -0
- pydefine-1.0.0.dist-info/RECORD +13 -0
- pydefine-1.0.0.dist-info/WHEEL +5 -0
- pydefine-1.0.0.dist-info/entry_points.txt +3 -0
- pydefine-1.0.0.dist-info/licenses/LICENSE +21 -0
- pydefine-1.0.0.dist-info/top_level.txt +1 -0
pydefine/mapping.py
ADDED
|
@@ -0,0 +1,1037 @@
|
|
|
1
|
+
"""
|
|
2
|
+
pydefine.mapping
|
|
3
|
+
~~~~~~~~~~~~~~~~
|
|
4
|
+
|
|
5
|
+
Complete mapping of all Python built-in exceptions to beginner-friendly
|
|
6
|
+
explanations, fix suggestions, and classification tags.
|
|
7
|
+
|
|
8
|
+
This module contains EXCEPTION_MAP which maps exception class names to
|
|
9
|
+
dictionaries containing:
|
|
10
|
+
- simple_explanation: 2-3 line explanation in simple English
|
|
11
|
+
- fix_suggestion: One-line actionable fix
|
|
12
|
+
- tags: List of classification keywords
|
|
13
|
+
- emoji: Optional emoji for visual identification
|
|
14
|
+
|
|
15
|
+
All explanations are written for absolute beginners with no jargon.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
# Complete mapping of 80+ built-in Python exceptions
|
|
19
|
+
EXCEPTION_MAP = {
|
|
20
|
+
# =========================================================================
|
|
21
|
+
# SYNTAX ERRORS
|
|
22
|
+
# =========================================================================
|
|
23
|
+
"SyntaxError": {
|
|
24
|
+
"simple_explanation": (
|
|
25
|
+
"You wrote Python code that doesn't follow the language rules. "
|
|
26
|
+
"Python couldn't understand what you typed. "
|
|
27
|
+
"This is like writing a sentence with wrong grammar 📝"
|
|
28
|
+
),
|
|
29
|
+
"fix_suggestion": (
|
|
30
|
+
"Check for missing colons (:), unmatched parentheses/brackets, "
|
|
31
|
+
"or typos in keywords like 'if', 'for', 'def'"
|
|
32
|
+
),
|
|
33
|
+
"tags": ["syntax", "grammar", "typo", "beginner"],
|
|
34
|
+
"emoji": "📝"
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
"IndentationError": {
|
|
38
|
+
"simple_explanation": (
|
|
39
|
+
"Your code has wrong spacing at the beginning of a line. "
|
|
40
|
+
"Python needs consistent spaces or tabs to understand code blocks. "
|
|
41
|
+
"Think of it like paragraphs that need proper alignment 📏"
|
|
42
|
+
),
|
|
43
|
+
"fix_suggestion": (
|
|
44
|
+
"Make sure all lines in the same block have the same number of spaces "
|
|
45
|
+
"(usually 4 spaces). Don't mix tabs and spaces"
|
|
46
|
+
),
|
|
47
|
+
"tags": ["syntax", "indentation", "spacing", "whitespace"],
|
|
48
|
+
"emoji": "📏"
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
"TabError": {
|
|
52
|
+
"simple_explanation": (
|
|
53
|
+
"You mixed tabs (Tab key) and spaces for indentation. "
|
|
54
|
+
"Python gets confused when you use both in the same file. "
|
|
55
|
+
"It's like mixing two different measuring systems 🔀"
|
|
56
|
+
),
|
|
57
|
+
"fix_suggestion": (
|
|
58
|
+
"Use only spaces (4 spaces per indent level) or only tabs, "
|
|
59
|
+
"never mix them. Most editors can convert tabs to spaces"
|
|
60
|
+
),
|
|
61
|
+
"tags": ["syntax", "indentation", "tabs", "whitespace"],
|
|
62
|
+
"emoji": "🔀"
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
# =========================================================================
|
|
66
|
+
# NAME AND ATTRIBUTE ERRORS
|
|
67
|
+
# =========================================================================
|
|
68
|
+
"NameError": {
|
|
69
|
+
"simple_explanation": (
|
|
70
|
+
"You tried to use a variable or function name that doesn't exist yet. "
|
|
71
|
+
"Python doesn't know what you're talking about. "
|
|
72
|
+
"It's like calling someone who isn't in the room 🤷"
|
|
73
|
+
),
|
|
74
|
+
"fix_suggestion": (
|
|
75
|
+
"Check spelling, make sure you defined the variable first, "
|
|
76
|
+
"or import the module that contains it"
|
|
77
|
+
),
|
|
78
|
+
"tags": ["name", "variable", "undefined", "scope"],
|
|
79
|
+
"emoji": "🤷"
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
"UnboundLocalError": {
|
|
83
|
+
"simple_explanation": (
|
|
84
|
+
"You tried to use a variable inside a function before giving it a value. "
|
|
85
|
+
"Python knows you want a local variable but you haven't set it yet. "
|
|
86
|
+
"It's like opening an empty box 📦"
|
|
87
|
+
),
|
|
88
|
+
"fix_suggestion": (
|
|
89
|
+
"Assign a value to the variable before using it, "
|
|
90
|
+
"or use 'global' keyword if you meant to use an outside variable"
|
|
91
|
+
),
|
|
92
|
+
"tags": ["name", "variable", "scope", "local"],
|
|
93
|
+
"emoji": "📦"
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
"AttributeError": {
|
|
97
|
+
"simple_explanation": (
|
|
98
|
+
"You tried to access a property or method that doesn't exist on an object. "
|
|
99
|
+
"The thing you're working with doesn't have that feature. "
|
|
100
|
+
"It's like trying to open a car door that isn't there 🚗"
|
|
101
|
+
),
|
|
102
|
+
"fix_suggestion": (
|
|
103
|
+
"Check the correct attribute name using dir(object), "
|
|
104
|
+
"or verify the object type is what you expect"
|
|
105
|
+
),
|
|
106
|
+
"tags": ["attribute", "object", "method", "property"],
|
|
107
|
+
"emoji": "🚗"
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
# =========================================================================
|
|
111
|
+
# TYPE ERRORS
|
|
112
|
+
# =========================================================================
|
|
113
|
+
"TypeError": {
|
|
114
|
+
"simple_explanation": (
|
|
115
|
+
"You tried to do something with the wrong type of data. "
|
|
116
|
+
"Like trying to add a number to a word - they don't mix. "
|
|
117
|
+
"Python needs compatible types to work together 🔢➕📝"
|
|
118
|
+
),
|
|
119
|
+
"fix_suggestion": (
|
|
120
|
+
"Convert data to the right type (e.g., int(), str(), list()), "
|
|
121
|
+
"or check if you're using the correct operation"
|
|
122
|
+
),
|
|
123
|
+
"tags": ["type", "conversion", "operation", "mismatch"],
|
|
124
|
+
"emoji": "🔢"
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
# =========================================================================
|
|
128
|
+
# VALUE ERRORS
|
|
129
|
+
# =========================================================================
|
|
130
|
+
"ValueError": {
|
|
131
|
+
"simple_explanation": (
|
|
132
|
+
"The data type is correct but the actual value doesn't make sense. "
|
|
133
|
+
"Like trying to convert the word 'hello' into a number. "
|
|
134
|
+
"The format or content is wrong 🎯"
|
|
135
|
+
),
|
|
136
|
+
"fix_suggestion": (
|
|
137
|
+
"Check if the input value is valid for what you're trying to do. "
|
|
138
|
+
"Add validation or try/except to handle bad values"
|
|
139
|
+
),
|
|
140
|
+
"tags": ["value", "invalid", "format", "conversion"],
|
|
141
|
+
"emoji": "🎯"
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
# =========================================================================
|
|
145
|
+
# KEY AND INDEX ERRORS
|
|
146
|
+
# =========================================================================
|
|
147
|
+
"KeyError": {
|
|
148
|
+
"simple_explanation": (
|
|
149
|
+
"You tried to get a value from a dictionary using a key that doesn't exist. "
|
|
150
|
+
"It's like looking for a word in a dictionary that isn't there. "
|
|
151
|
+
"The key you asked for is missing 🔑"
|
|
152
|
+
),
|
|
153
|
+
"fix_suggestion": (
|
|
154
|
+
"Use dict.get(key, default) instead of dict[key], "
|
|
155
|
+
"or check if the key exists with 'key in dict' first"
|
|
156
|
+
),
|
|
157
|
+
"tags": ["key", "dictionary", "lookup", "missing"],
|
|
158
|
+
"emoji": "🔑"
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
"IndexError": {
|
|
162
|
+
"simple_explanation": (
|
|
163
|
+
"You tried to access a position in a list that doesn't exist. "
|
|
164
|
+
"Like trying to get the 10th item when there are only 5 items. "
|
|
165
|
+
"The index is out of range 📊"
|
|
166
|
+
),
|
|
167
|
+
"fix_suggestion": (
|
|
168
|
+
"Check the length with len() before accessing, "
|
|
169
|
+
"or use negative indices to count from the end"
|
|
170
|
+
),
|
|
171
|
+
"tags": ["index", "list", "sequence", "out-of-bounds"],
|
|
172
|
+
"emoji": "📊"
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
# =========================================================================
|
|
176
|
+
# ARITHMETIC ERRORS
|
|
177
|
+
# =========================================================================
|
|
178
|
+
"ZeroDivisionError": {
|
|
179
|
+
"simple_explanation": (
|
|
180
|
+
"You tried to divide a number by zero, which is impossible in math. "
|
|
181
|
+
"Division by zero breaks the universe's math rules. "
|
|
182
|
+
"Python can't calculate infinity ➗"
|
|
183
|
+
),
|
|
184
|
+
"fix_suggestion": (
|
|
185
|
+
"Check if the divisor is zero before dividing, "
|
|
186
|
+
"or add a condition to handle zero values"
|
|
187
|
+
),
|
|
188
|
+
"tags": ["arithmetic", "division", "zero", "math"],
|
|
189
|
+
"emoji": "➗"
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
"OverflowError": {
|
|
193
|
+
"simple_explanation": (
|
|
194
|
+
"A number got too big for Python to handle in a calculation. "
|
|
195
|
+
"You exceeded the maximum size for this type of number. "
|
|
196
|
+
"It's like filling a cup that's too small 🌊"
|
|
197
|
+
),
|
|
198
|
+
"fix_suggestion": (
|
|
199
|
+
"Use smaller numbers, break calculation into steps, "
|
|
200
|
+
"or use Python's unlimited precision integers"
|
|
201
|
+
),
|
|
202
|
+
"tags": ["arithmetic", "overflow", "large-number", "math"],
|
|
203
|
+
"emoji": "🌊"
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
"FloatingPointError": {
|
|
207
|
+
"simple_explanation": (
|
|
208
|
+
"A decimal number calculation failed or produced an invalid result. "
|
|
209
|
+
"This happens with very precise math operations. "
|
|
210
|
+
"Floating point math has limits 🔢"
|
|
211
|
+
),
|
|
212
|
+
"fix_suggestion": (
|
|
213
|
+
"Use the decimal module for precise calculations, "
|
|
214
|
+
"or check for special values like infinity or NaN"
|
|
215
|
+
),
|
|
216
|
+
"tags": ["arithmetic", "float", "precision", "math"],
|
|
217
|
+
"emoji": "🔢"
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
"ArithmeticError": {
|
|
221
|
+
"simple_explanation": (
|
|
222
|
+
"A general math error occurred during a calculation. "
|
|
223
|
+
"This is the parent class for all arithmetic problems. "
|
|
224
|
+
"Something went wrong with numbers ➕"
|
|
225
|
+
),
|
|
226
|
+
"fix_suggestion": (
|
|
227
|
+
"Check the specific error type for more details. "
|
|
228
|
+
"Validate input values before calculations"
|
|
229
|
+
),
|
|
230
|
+
"tags": ["arithmetic", "math", "calculation", "general"],
|
|
231
|
+
"emoji": "➕"
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
# =========================================================================
|
|
235
|
+
# FILE AND OS ERRORS
|
|
236
|
+
# =========================================================================
|
|
237
|
+
"FileNotFoundError": {
|
|
238
|
+
"simple_explanation": (
|
|
239
|
+
"Python couldn't find the file you're trying to open or use. "
|
|
240
|
+
"The file doesn't exist at the path you specified. "
|
|
241
|
+
"It's like looking for a book that isn't on the shelf 📁"
|
|
242
|
+
),
|
|
243
|
+
"fix_suggestion": (
|
|
244
|
+
"Check the file path spelling, verify the file exists, "
|
|
245
|
+
"or create the file if it should exist"
|
|
246
|
+
),
|
|
247
|
+
"tags": ["file", "path", "io", "missing"],
|
|
248
|
+
"emoji": "📁"
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
"FileExistsError": {
|
|
252
|
+
"simple_explanation": (
|
|
253
|
+
"You tried to create a file that already exists. "
|
|
254
|
+
"Python won't overwrite it without permission. "
|
|
255
|
+
"The filename is already taken 📄"
|
|
256
|
+
),
|
|
257
|
+
"fix_suggestion": (
|
|
258
|
+
"Choose a different filename, delete the old file first, "
|
|
259
|
+
"or open the file in append/write mode"
|
|
260
|
+
),
|
|
261
|
+
"tags": ["file", "exists", "io", "duplicate"],
|
|
262
|
+
"emoji": "📄"
|
|
263
|
+
},
|
|
264
|
+
|
|
265
|
+
"PermissionError": {
|
|
266
|
+
"simple_explanation": (
|
|
267
|
+
"You don't have permission to access, read, or modify this file or folder. "
|
|
268
|
+
"The operating system blocked your request for security. "
|
|
269
|
+
"Access denied 🔒"
|
|
270
|
+
),
|
|
271
|
+
"fix_suggestion": (
|
|
272
|
+
"Run as administrator/sudo, check file permissions, "
|
|
273
|
+
"or ask the owner to grant you access"
|
|
274
|
+
),
|
|
275
|
+
"tags": ["file", "permission", "access", "security"],
|
|
276
|
+
"emoji": "🔒"
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
"IsADirectoryError": {
|
|
280
|
+
"simple_explanation": (
|
|
281
|
+
"You tried to open a folder as if it were a file. "
|
|
282
|
+
"Folders and files need different operations. "
|
|
283
|
+
"You can't read a folder like a text file 📂"
|
|
284
|
+
),
|
|
285
|
+
"fix_suggestion": (
|
|
286
|
+
"Use os.listdir() to read folder contents, "
|
|
287
|
+
"or check if the path is a file before opening"
|
|
288
|
+
),
|
|
289
|
+
"tags": ["file", "directory", "io", "type"],
|
|
290
|
+
"emoji": "📂"
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
"NotADirectoryError": {
|
|
294
|
+
"simple_explanation": (
|
|
295
|
+
"You tried to use a file as if it were a folder. "
|
|
296
|
+
"The path you gave points to a file, not a directory. "
|
|
297
|
+
"You can't list contents of a file 📄"
|
|
298
|
+
),
|
|
299
|
+
"fix_suggestion": (
|
|
300
|
+
"Check if the path is a directory with os.path.isdir(), "
|
|
301
|
+
"or use the correct path to the folder"
|
|
302
|
+
),
|
|
303
|
+
"tags": ["file", "directory", "io", "type"],
|
|
304
|
+
"emoji": "📄"
|
|
305
|
+
},
|
|
306
|
+
|
|
307
|
+
"IOError": {
|
|
308
|
+
"simple_explanation": (
|
|
309
|
+
"An input/output operation failed when working with files or streams. "
|
|
310
|
+
"Something went wrong reading or writing data. "
|
|
311
|
+
"Data transfer had a problem 💾"
|
|
312
|
+
),
|
|
313
|
+
"fix_suggestion": (
|
|
314
|
+
"Check if the file is open, device is connected, "
|
|
315
|
+
"or if there's enough disk space"
|
|
316
|
+
),
|
|
317
|
+
"tags": ["io", "file", "stream", "read-write"],
|
|
318
|
+
"emoji": "💾"
|
|
319
|
+
},
|
|
320
|
+
|
|
321
|
+
"OSError": {
|
|
322
|
+
"simple_explanation": (
|
|
323
|
+
"The operating system returned an error. "
|
|
324
|
+
"This could be file issues, network problems, or system limits. "
|
|
325
|
+
"Something went wrong at the system level 🖥️"
|
|
326
|
+
),
|
|
327
|
+
"fix_suggestion": (
|
|
328
|
+
"Check system resources, file permissions, network connection, "
|
|
329
|
+
"or read the detailed error message for specifics"
|
|
330
|
+
),
|
|
331
|
+
"tags": ["os", "system", "general", "file"],
|
|
332
|
+
"emoji": "🖥️"
|
|
333
|
+
},
|
|
334
|
+
|
|
335
|
+
"EOFError": {
|
|
336
|
+
"simple_explanation": (
|
|
337
|
+
"Python reached the end of a file or input unexpectedly. "
|
|
338
|
+
"The input() function got closed without receiving data. "
|
|
339
|
+
"No more data to read 📭"
|
|
340
|
+
),
|
|
341
|
+
"fix_suggestion": (
|
|
342
|
+
"Make sure there's input available, handle Ctrl+D/Ctrl+Z gracefully, "
|
|
343
|
+
"or check if the file has content"
|
|
344
|
+
),
|
|
345
|
+
"tags": ["io", "input", "eof", "stream"],
|
|
346
|
+
"emoji": "📭"
|
|
347
|
+
},
|
|
348
|
+
|
|
349
|
+
# =========================================================================
|
|
350
|
+
# IMPORT ERRORS
|
|
351
|
+
# =========================================================================
|
|
352
|
+
"ImportError": {
|
|
353
|
+
"simple_explanation": (
|
|
354
|
+
"Python couldn't import a module you requested. "
|
|
355
|
+
"The package might not be installed or the name is wrong. "
|
|
356
|
+
"Import failed 📦"
|
|
357
|
+
),
|
|
358
|
+
"fix_suggestion": (
|
|
359
|
+
"Install the package with pip install, check spelling, "
|
|
360
|
+
"or verify the module exists in your environment"
|
|
361
|
+
),
|
|
362
|
+
"tags": ["import", "module", "package", "missing"],
|
|
363
|
+
"emoji": "📦"
|
|
364
|
+
},
|
|
365
|
+
|
|
366
|
+
"ModuleNotFoundError": {
|
|
367
|
+
"simple_explanation": (
|
|
368
|
+
"Python can't find the module you're trying to import. "
|
|
369
|
+
"The module doesn't exist or isn't installed. "
|
|
370
|
+
"Module is missing 🔍"
|
|
371
|
+
),
|
|
372
|
+
"fix_suggestion": (
|
|
373
|
+
"Install with 'pip install module_name', check spelling, "
|
|
374
|
+
"or add the module's directory to Python path"
|
|
375
|
+
),
|
|
376
|
+
"tags": ["import", "module", "not-found", "pip"],
|
|
377
|
+
"emoji": "🔍"
|
|
378
|
+
},
|
|
379
|
+
|
|
380
|
+
# =========================================================================
|
|
381
|
+
# ASSERTION AND RUNTIME ERRORS
|
|
382
|
+
# =========================================================================
|
|
383
|
+
"AssertionError": {
|
|
384
|
+
"simple_explanation": (
|
|
385
|
+
"An assert statement failed - a condition you expected to be true was false. "
|
|
386
|
+
"This is a test that didn't pass. "
|
|
387
|
+
"Your assumption was wrong ✋"
|
|
388
|
+
),
|
|
389
|
+
"fix_suggestion": (
|
|
390
|
+
"Check why the condition is false, fix the logic, "
|
|
391
|
+
"or remove the assert if it's no longer needed"
|
|
392
|
+
),
|
|
393
|
+
"tags": ["assertion", "test", "condition", "debug"],
|
|
394
|
+
"emoji": "✋"
|
|
395
|
+
},
|
|
396
|
+
|
|
397
|
+
"RuntimeError": {
|
|
398
|
+
"simple_explanation": (
|
|
399
|
+
"An error happened while the program was running that doesn't fit other categories. "
|
|
400
|
+
"Something unexpected went wrong during execution. "
|
|
401
|
+
"General runtime problem ⚠️"
|
|
402
|
+
),
|
|
403
|
+
"fix_suggestion": (
|
|
404
|
+
"Read the detailed error message for context. "
|
|
405
|
+
"Debug the specific operation that failed"
|
|
406
|
+
),
|
|
407
|
+
"tags": ["runtime", "general", "execution"],
|
|
408
|
+
"emoji": "⚠️"
|
|
409
|
+
},
|
|
410
|
+
|
|
411
|
+
"RecursionError": {
|
|
412
|
+
"simple_explanation": (
|
|
413
|
+
"A function called itself too many times without stopping. "
|
|
414
|
+
"You have infinite recursion that exceeded Python's limit. "
|
|
415
|
+
"Stack overflow from deep recursion 🔁"
|
|
416
|
+
),
|
|
417
|
+
"fix_suggestion": (
|
|
418
|
+
"Add a base case to stop recursion, use iteration instead, "
|
|
419
|
+
"or increase recursion limit with sys.setrecursionlimit()"
|
|
420
|
+
),
|
|
421
|
+
"tags": ["recursion", "stack", "infinite", "function"],
|
|
422
|
+
"emoji": "🔁"
|
|
423
|
+
},
|
|
424
|
+
|
|
425
|
+
"NotImplementedError": {
|
|
426
|
+
"simple_explanation": (
|
|
427
|
+
"A method or function is defined but not actually coded yet. "
|
|
428
|
+
"The developer left it as a placeholder. "
|
|
429
|
+
"Feature not implemented 🚧"
|
|
430
|
+
),
|
|
431
|
+
"fix_suggestion": (
|
|
432
|
+
"Implement the method, use a different method, "
|
|
433
|
+
"or wait for the developer to complete this feature"
|
|
434
|
+
),
|
|
435
|
+
"tags": ["implementation", "abstract", "incomplete", "todo"],
|
|
436
|
+
"emoji": "🚧"
|
|
437
|
+
},
|
|
438
|
+
|
|
439
|
+
# =========================================================================
|
|
440
|
+
# MEMORY ERRORS
|
|
441
|
+
# =========================================================================
|
|
442
|
+
"MemoryError": {
|
|
443
|
+
"simple_explanation": (
|
|
444
|
+
"Python ran out of available memory (RAM). "
|
|
445
|
+
"You're trying to store or process too much data. "
|
|
446
|
+
"Not enough memory 🧠"
|
|
447
|
+
),
|
|
448
|
+
"fix_suggestion": (
|
|
449
|
+
"Process data in smaller chunks, close unused objects, "
|
|
450
|
+
"use generators instead of lists, or add more RAM"
|
|
451
|
+
),
|
|
452
|
+
"tags": ["memory", "ram", "resource", "overflow"],
|
|
453
|
+
"emoji": "🧠"
|
|
454
|
+
},
|
|
455
|
+
|
|
456
|
+
# =========================================================================
|
|
457
|
+
# STOP ITERATION
|
|
458
|
+
# =========================================================================
|
|
459
|
+
"StopIteration": {
|
|
460
|
+
"simple_explanation": (
|
|
461
|
+
"An iterator ran out of items when you called next() on it. "
|
|
462
|
+
"This is normal - it means 'no more items left'. "
|
|
463
|
+
"Iterator is exhausted 🔚"
|
|
464
|
+
),
|
|
465
|
+
"fix_suggestion": (
|
|
466
|
+
"This is usually caught automatically in loops. "
|
|
467
|
+
"Use for-loops instead of manually calling next()"
|
|
468
|
+
),
|
|
469
|
+
"tags": ["iterator", "loop", "exhausted", "normal"],
|
|
470
|
+
"emoji": "🔚"
|
|
471
|
+
},
|
|
472
|
+
|
|
473
|
+
"StopAsyncIteration": {
|
|
474
|
+
"simple_explanation": (
|
|
475
|
+
"An async iterator ran out of items. "
|
|
476
|
+
"Similar to StopIteration but for async/await code. "
|
|
477
|
+
"Async iterator finished 🔚"
|
|
478
|
+
),
|
|
479
|
+
"fix_suggestion": (
|
|
480
|
+
"This is normal behavior. Use 'async for' loops which handle this automatically"
|
|
481
|
+
),
|
|
482
|
+
"tags": ["iterator", "async", "exhausted", "normal"],
|
|
483
|
+
"emoji": "🔚"
|
|
484
|
+
},
|
|
485
|
+
|
|
486
|
+
# =========================================================================
|
|
487
|
+
# KEYBOARD AND SYSTEM
|
|
488
|
+
# =========================================================================
|
|
489
|
+
"KeyboardInterrupt": {
|
|
490
|
+
"simple_explanation": (
|
|
491
|
+
"You pressed Ctrl+C to stop the program manually. "
|
|
492
|
+
"This is intentional - you cancelled execution. "
|
|
493
|
+
"User interrupted ⌨️"
|
|
494
|
+
),
|
|
495
|
+
"fix_suggestion": (
|
|
496
|
+
"This is normal. If you want to catch it, use try/except KeyboardInterrupt "
|
|
497
|
+
"to clean up before exiting"
|
|
498
|
+
),
|
|
499
|
+
"tags": ["interrupt", "cancel", "ctrl-c", "user"],
|
|
500
|
+
"emoji": "⌨️"
|
|
501
|
+
},
|
|
502
|
+
|
|
503
|
+
"SystemExit": {
|
|
504
|
+
"simple_explanation": (
|
|
505
|
+
"The program called sys.exit() to quit intentionally. "
|
|
506
|
+
"This is a clean way to end the program. "
|
|
507
|
+
"Intentional exit 🚪"
|
|
508
|
+
),
|
|
509
|
+
"fix_suggestion": (
|
|
510
|
+
"This is normal. If catching it, don't prevent legitimate exits. "
|
|
511
|
+
"Check the exit code for success/failure"
|
|
512
|
+
),
|
|
513
|
+
"tags": ["exit", "quit", "system", "intentional"],
|
|
514
|
+
"emoji": "🚪"
|
|
515
|
+
},
|
|
516
|
+
|
|
517
|
+
"SystemError": {
|
|
518
|
+
"simple_explanation": (
|
|
519
|
+
"Python's interpreter encountered an internal error. "
|
|
520
|
+
"This is rare and usually a bug in Python itself or a C extension. "
|
|
521
|
+
"Internal Python error 🐍"
|
|
522
|
+
),
|
|
523
|
+
"fix_suggestion": (
|
|
524
|
+
"Update Python to the latest version, check if a C extension is buggy, "
|
|
525
|
+
"or report this bug to Python developers"
|
|
526
|
+
),
|
|
527
|
+
"tags": ["system", "internal", "interpreter", "rare"],
|
|
528
|
+
"emoji": "🐍"
|
|
529
|
+
},
|
|
530
|
+
|
|
531
|
+
"GeneratorExit": {
|
|
532
|
+
"simple_explanation": (
|
|
533
|
+
"A generator was closed while it was still running. "
|
|
534
|
+
"This happens when you call .close() on a generator. "
|
|
535
|
+
"Generator was stopped early ⏹️"
|
|
536
|
+
),
|
|
537
|
+
"fix_suggestion": (
|
|
538
|
+
"This is usually intentional. Handle cleanup in 'finally' blocks if needed"
|
|
539
|
+
),
|
|
540
|
+
"tags": ["generator", "close", "cleanup", "normal"],
|
|
541
|
+
"emoji": "⏹️"
|
|
542
|
+
},
|
|
543
|
+
|
|
544
|
+
# =========================================================================
|
|
545
|
+
# UNICODE ERRORS
|
|
546
|
+
# =========================================================================
|
|
547
|
+
"UnicodeError": {
|
|
548
|
+
"simple_explanation": (
|
|
549
|
+
"A problem occurred with text encoding or decoding. "
|
|
550
|
+
"Python couldn't convert between text formats properly. "
|
|
551
|
+
"Text encoding problem 🔤"
|
|
552
|
+
),
|
|
553
|
+
"fix_suggestion": (
|
|
554
|
+
"Specify encoding explicitly (utf-8), handle errors parameter, "
|
|
555
|
+
"or check source text encoding"
|
|
556
|
+
),
|
|
557
|
+
"tags": ["unicode", "encoding", "text", "charset"],
|
|
558
|
+
"emoji": "🔤"
|
|
559
|
+
},
|
|
560
|
+
|
|
561
|
+
"UnicodeDecodeError": {
|
|
562
|
+
"simple_explanation": (
|
|
563
|
+
"Python couldn't decode bytes into text using the specified encoding. "
|
|
564
|
+
"The byte sequence doesn't match the encoding you specified. "
|
|
565
|
+
"Can't decode text 📥"
|
|
566
|
+
),
|
|
567
|
+
"fix_suggestion": (
|
|
568
|
+
"Use correct encoding (try utf-8), use errors='ignore' or 'replace', "
|
|
569
|
+
"or detect encoding with chardet library"
|
|
570
|
+
),
|
|
571
|
+
"tags": ["unicode", "decode", "encoding", "text"],
|
|
572
|
+
"emoji": "📥"
|
|
573
|
+
},
|
|
574
|
+
|
|
575
|
+
"UnicodeEncodeError": {
|
|
576
|
+
"simple_explanation": (
|
|
577
|
+
"Python couldn't encode text into bytes using the specified encoding. "
|
|
578
|
+
"The text contains characters that don't exist in the target encoding. "
|
|
579
|
+
"Can't encode text 📤"
|
|
580
|
+
),
|
|
581
|
+
"fix_suggestion": (
|
|
582
|
+
"Use utf-8 encoding which supports all characters, "
|
|
583
|
+
"or use errors='ignore'/'replace' to skip problem characters"
|
|
584
|
+
),
|
|
585
|
+
"tags": ["unicode", "encode", "encoding", "text"],
|
|
586
|
+
"emoji": "📤"
|
|
587
|
+
},
|
|
588
|
+
|
|
589
|
+
"UnicodeTranslateError": {
|
|
590
|
+
"simple_explanation": (
|
|
591
|
+
"Python couldn't translate characters during text processing. "
|
|
592
|
+
"Character mapping or translation failed. "
|
|
593
|
+
"Can't translate text 🔄"
|
|
594
|
+
),
|
|
595
|
+
"fix_suggestion": (
|
|
596
|
+
"Check the translation table, use errors='ignore', "
|
|
597
|
+
"or handle special characters separately"
|
|
598
|
+
),
|
|
599
|
+
"tags": ["unicode", "translate", "mapping", "text"],
|
|
600
|
+
"emoji": "🔄"
|
|
601
|
+
},
|
|
602
|
+
|
|
603
|
+
# =========================================================================
|
|
604
|
+
# LOOKUP ERRORS
|
|
605
|
+
# =========================================================================
|
|
606
|
+
"LookupError": {
|
|
607
|
+
"simple_explanation": (
|
|
608
|
+
"A general error for failed lookups in sequences or mappings. "
|
|
609
|
+
"Parent class of KeyError and IndexError. "
|
|
610
|
+
"Lookup failed 🔎"
|
|
611
|
+
),
|
|
612
|
+
"fix_suggestion": (
|
|
613
|
+
"Check the specific error (KeyError or IndexError) for details. "
|
|
614
|
+
"Validate keys/indices before accessing"
|
|
615
|
+
),
|
|
616
|
+
"tags": ["lookup", "general", "key", "index"],
|
|
617
|
+
"emoji": "🔎"
|
|
618
|
+
},
|
|
619
|
+
|
|
620
|
+
# =========================================================================
|
|
621
|
+
# REFERENCE ERROR
|
|
622
|
+
# =========================================================================
|
|
623
|
+
"ReferenceError": {
|
|
624
|
+
"simple_explanation": (
|
|
625
|
+
"A weak reference tried to access an object that was already garbage collected. "
|
|
626
|
+
"The object you referenced no longer exists. "
|
|
627
|
+
"Object was deleted 🗑️"
|
|
628
|
+
),
|
|
629
|
+
"fix_suggestion": (
|
|
630
|
+
"Check if weak reference is still alive before using, "
|
|
631
|
+
"or use strong references if object must persist"
|
|
632
|
+
),
|
|
633
|
+
"tags": ["reference", "weak", "garbage-collection", "memory"],
|
|
634
|
+
"emoji": "🗑️"
|
|
635
|
+
},
|
|
636
|
+
|
|
637
|
+
# =========================================================================
|
|
638
|
+
# BUFFER ERROR
|
|
639
|
+
# =========================================================================
|
|
640
|
+
"BufferError": {
|
|
641
|
+
"simple_explanation": (
|
|
642
|
+
"An operation failed on a buffer object. "
|
|
643
|
+
"Usually happens when trying to modify an object while it's being accessed. "
|
|
644
|
+
"Buffer conflict 📦"
|
|
645
|
+
),
|
|
646
|
+
"fix_suggestion": (
|
|
647
|
+
"Release buffer locks, avoid modifying objects during buffer operations, "
|
|
648
|
+
"or copy data before modifying"
|
|
649
|
+
),
|
|
650
|
+
"tags": ["buffer", "memory", "conflict", "access"],
|
|
651
|
+
"emoji": "📦"
|
|
652
|
+
},
|
|
653
|
+
|
|
654
|
+
# =========================================================================
|
|
655
|
+
# CONNECTION ERRORS
|
|
656
|
+
# =========================================================================
|
|
657
|
+
"ConnectionError": {
|
|
658
|
+
"simple_explanation": (
|
|
659
|
+
"A network connection failed or was interrupted. "
|
|
660
|
+
"Parent class for all connection-related errors. "
|
|
661
|
+
"Connection problem 🌐"
|
|
662
|
+
),
|
|
663
|
+
"fix_suggestion": (
|
|
664
|
+
"Check network connection, verify server is running, "
|
|
665
|
+
"check firewall settings, or retry the connection"
|
|
666
|
+
),
|
|
667
|
+
"tags": ["connection", "network", "socket", "general"],
|
|
668
|
+
"emoji": "🌐"
|
|
669
|
+
},
|
|
670
|
+
|
|
671
|
+
"BrokenPipeError": {
|
|
672
|
+
"simple_explanation": (
|
|
673
|
+
"You tried to write to a pipe or socket that was closed on the other end. "
|
|
674
|
+
"The receiving end disconnected unexpectedly. "
|
|
675
|
+
"Pipe broken 📡"
|
|
676
|
+
),
|
|
677
|
+
"fix_suggestion": (
|
|
678
|
+
"Check if the other process is running, handle disconnections gracefully, "
|
|
679
|
+
"or add retry logic"
|
|
680
|
+
),
|
|
681
|
+
"tags": ["connection", "pipe", "socket", "disconnect"],
|
|
682
|
+
"emoji": "📡"
|
|
683
|
+
},
|
|
684
|
+
|
|
685
|
+
"ConnectionAbortedError": {
|
|
686
|
+
"simple_explanation": (
|
|
687
|
+
"The connection was aborted by the software on your computer. "
|
|
688
|
+
"Your side closed the connection. "
|
|
689
|
+
"Connection aborted locally ❌"
|
|
690
|
+
),
|
|
691
|
+
"fix_suggestion": (
|
|
692
|
+
"Check if your firewall blocked it, verify network settings, "
|
|
693
|
+
"or check for software conflicts"
|
|
694
|
+
),
|
|
695
|
+
"tags": ["connection", "abort", "network", "local"],
|
|
696
|
+
"emoji": "❌"
|
|
697
|
+
},
|
|
698
|
+
|
|
699
|
+
"ConnectionRefusedError": {
|
|
700
|
+
"simple_explanation": (
|
|
701
|
+
"The remote computer actively refused the connection. "
|
|
702
|
+
"The server isn't accepting connections on that port. "
|
|
703
|
+
"Connection refused by server 🚫"
|
|
704
|
+
),
|
|
705
|
+
"fix_suggestion": (
|
|
706
|
+
"Verify server is running, check the port number, "
|
|
707
|
+
"check firewall rules, or verify the address"
|
|
708
|
+
),
|
|
709
|
+
"tags": ["connection", "refused", "server", "port"],
|
|
710
|
+
"emoji": "🚫"
|
|
711
|
+
},
|
|
712
|
+
|
|
713
|
+
"ConnectionResetError": {
|
|
714
|
+
"simple_explanation": (
|
|
715
|
+
"The connection was forcibly closed by the remote computer. "
|
|
716
|
+
"The other side dropped the connection suddenly. "
|
|
717
|
+
"Connection reset by peer 🔌"
|
|
718
|
+
),
|
|
719
|
+
"fix_suggestion": (
|
|
720
|
+
"Check server stability, add reconnection logic, "
|
|
721
|
+
"verify network stability, or check for server crashes"
|
|
722
|
+
),
|
|
723
|
+
"tags": ["connection", "reset", "network", "remote"],
|
|
724
|
+
"emoji": "🔌"
|
|
725
|
+
},
|
|
726
|
+
|
|
727
|
+
# =========================================================================
|
|
728
|
+
# TIMEOUT
|
|
729
|
+
# =========================================================================
|
|
730
|
+
"TimeoutError": {
|
|
731
|
+
"simple_explanation": (
|
|
732
|
+
"An operation took too long and exceeded the time limit. "
|
|
733
|
+
"The connection or operation timed out. "
|
|
734
|
+
"Operation timed out ⏱️"
|
|
735
|
+
),
|
|
736
|
+
"fix_suggestion": (
|
|
737
|
+
"Increase timeout value, check network speed, "
|
|
738
|
+
"optimize slow operations, or check server response time"
|
|
739
|
+
),
|
|
740
|
+
"tags": ["timeout", "slow", "network", "time-limit"],
|
|
741
|
+
"emoji": "⏱️"
|
|
742
|
+
},
|
|
743
|
+
|
|
744
|
+
# =========================================================================
|
|
745
|
+
# CHILD PROCESS ERROR
|
|
746
|
+
# =========================================================================
|
|
747
|
+
"ChildProcessError": {
|
|
748
|
+
"simple_explanation": (
|
|
749
|
+
"An operation on a child process failed. "
|
|
750
|
+
"Something went wrong managing subprocess execution. "
|
|
751
|
+
"Child process error 👶"
|
|
752
|
+
),
|
|
753
|
+
"fix_suggestion": (
|
|
754
|
+
"Check if subprocess command is valid, verify subprocess permissions, "
|
|
755
|
+
"or check if child process exited unexpectedly"
|
|
756
|
+
),
|
|
757
|
+
"tags": ["subprocess", "process", "child", "execution"],
|
|
758
|
+
"emoji": "👶"
|
|
759
|
+
},
|
|
760
|
+
|
|
761
|
+
# =========================================================================
|
|
762
|
+
# BLOCKING IO ERROR
|
|
763
|
+
# =========================================================================
|
|
764
|
+
"BlockingIOError": {
|
|
765
|
+
"simple_explanation": (
|
|
766
|
+
"An I/O operation would block but was set to non-blocking mode. "
|
|
767
|
+
"The operation can't complete immediately. "
|
|
768
|
+
"Would block in non-blocking mode 🚦"
|
|
769
|
+
),
|
|
770
|
+
"fix_suggestion": (
|
|
771
|
+
"Use select/poll to wait for readiness, switch to blocking mode, "
|
|
772
|
+
"or use async I/O"
|
|
773
|
+
),
|
|
774
|
+
"tags": ["io", "blocking", "non-blocking", "socket"],
|
|
775
|
+
"emoji": "🚦"
|
|
776
|
+
},
|
|
777
|
+
|
|
778
|
+
# =========================================================================
|
|
779
|
+
# INTERRUPTED ERROR
|
|
780
|
+
# =========================================================================
|
|
781
|
+
"InterruptedError": {
|
|
782
|
+
"simple_explanation": (
|
|
783
|
+
"A system call was interrupted by a signal. "
|
|
784
|
+
"The operation was stopped by the operating system. "
|
|
785
|
+
"System call interrupted 📞"
|
|
786
|
+
),
|
|
787
|
+
"fix_suggestion": (
|
|
788
|
+
"Retry the operation, this is usually temporary. "
|
|
789
|
+
"Python often handles this automatically"
|
|
790
|
+
),
|
|
791
|
+
"tags": ["signal", "interrupt", "system-call", "temporary"],
|
|
792
|
+
"emoji": "📞"
|
|
793
|
+
},
|
|
794
|
+
|
|
795
|
+
# =========================================================================
|
|
796
|
+
# PROCESS LOOKUP ERROR
|
|
797
|
+
# =========================================================================
|
|
798
|
+
"ProcessLookupError": {
|
|
799
|
+
"simple_explanation": (
|
|
800
|
+
"A process you're trying to access doesn't exist. "
|
|
801
|
+
"The process ID you specified is invalid or the process ended. "
|
|
802
|
+
"Process not found 🔍"
|
|
803
|
+
),
|
|
804
|
+
"fix_suggestion": (
|
|
805
|
+
"Check if process is still running, verify process ID, "
|
|
806
|
+
"or handle process termination"
|
|
807
|
+
),
|
|
808
|
+
"tags": ["process", "pid", "not-found", "system"],
|
|
809
|
+
"emoji": "🔍"
|
|
810
|
+
},
|
|
811
|
+
|
|
812
|
+
# =========================================================================
|
|
813
|
+
# WARNING (BaseException subclass but listed for completeness)
|
|
814
|
+
# =========================================================================
|
|
815
|
+
"Warning": {
|
|
816
|
+
"simple_explanation": (
|
|
817
|
+
"A warning message was issued but didn't stop the program. "
|
|
818
|
+
"This is for messages about potential problems. "
|
|
819
|
+
"Warning issued ⚠️"
|
|
820
|
+
),
|
|
821
|
+
"fix_suggestion": (
|
|
822
|
+
"Read the warning message and fix the underlying issue. "
|
|
823
|
+
"Warnings can become errors in future versions"
|
|
824
|
+
),
|
|
825
|
+
"tags": ["warning", "notice", "potential-issue", "deprecation"],
|
|
826
|
+
"emoji": "⚠️"
|
|
827
|
+
},
|
|
828
|
+
|
|
829
|
+
"DeprecationWarning": {
|
|
830
|
+
"simple_explanation": (
|
|
831
|
+
"You're using a feature that will be removed in future Python versions. "
|
|
832
|
+
"The code works now but won't work later. "
|
|
833
|
+
"Feature is deprecated ⚠️"
|
|
834
|
+
),
|
|
835
|
+
"fix_suggestion": (
|
|
836
|
+
"Check documentation for the replacement feature. "
|
|
837
|
+
"Update code to use the new recommended method"
|
|
838
|
+
),
|
|
839
|
+
"tags": ["warning", "deprecation", "future", "compatibility"],
|
|
840
|
+
"emoji": "⚠️"
|
|
841
|
+
},
|
|
842
|
+
|
|
843
|
+
"UserWarning": {
|
|
844
|
+
"simple_explanation": (
|
|
845
|
+
"A warning issued by user code (via warnings.warn()). "
|
|
846
|
+
"The program detected something unusual but continued. "
|
|
847
|
+
"User-defined warning ⚠️"
|
|
848
|
+
),
|
|
849
|
+
"fix_suggestion": (
|
|
850
|
+
"Read the warning message for context. "
|
|
851
|
+
"Check the code that issued the warning"
|
|
852
|
+
),
|
|
853
|
+
"tags": ["warning", "user", "custom", "notice"],
|
|
854
|
+
"emoji": "⚠️"
|
|
855
|
+
},
|
|
856
|
+
|
|
857
|
+
"FutureWarning": {
|
|
858
|
+
"simple_explanation": (
|
|
859
|
+
"Code behavior will change in future versions. "
|
|
860
|
+
"This warns about changes that will affect you later. "
|
|
861
|
+
"Future behavior change ⚠️"
|
|
862
|
+
),
|
|
863
|
+
"fix_suggestion": (
|
|
864
|
+
"Read the warning and update code to match future behavior. "
|
|
865
|
+
"Check documentation for migration guide"
|
|
866
|
+
),
|
|
867
|
+
"tags": ["warning", "future", "change", "compatibility"],
|
|
868
|
+
"emoji": "⚠️"
|
|
869
|
+
},
|
|
870
|
+
|
|
871
|
+
"SyntaxWarning": {
|
|
872
|
+
"simple_explanation": (
|
|
873
|
+
"Python noticed suspicious syntax that might be a mistake. "
|
|
874
|
+
"The code runs but looks wrong. "
|
|
875
|
+
"Suspicious syntax ⚠️"
|
|
876
|
+
),
|
|
877
|
+
"fix_suggestion": (
|
|
878
|
+
"Review the flagged syntax. "
|
|
879
|
+
"Make sure your code does what you intend"
|
|
880
|
+
),
|
|
881
|
+
"tags": ["warning", "syntax", "suspicious", "potential-error"],
|
|
882
|
+
"emoji": "⚠️"
|
|
883
|
+
},
|
|
884
|
+
|
|
885
|
+
"RuntimeWarning": {
|
|
886
|
+
"simple_explanation": (
|
|
887
|
+
"A warning about suspicious runtime behavior. "
|
|
888
|
+
"Something looks wrong during execution. "
|
|
889
|
+
"Runtime warning ⚠️"
|
|
890
|
+
),
|
|
891
|
+
"fix_suggestion": (
|
|
892
|
+
"Investigate the warning message. "
|
|
893
|
+
"Check for logic errors or unexpected behavior"
|
|
894
|
+
),
|
|
895
|
+
"tags": ["warning", "runtime", "behavior", "suspicious"],
|
|
896
|
+
"emoji": "⚠️"
|
|
897
|
+
},
|
|
898
|
+
|
|
899
|
+
"ResourceWarning": {
|
|
900
|
+
"simple_explanation": (
|
|
901
|
+
"A resource (file, socket) wasn't properly closed. "
|
|
902
|
+
"You have a resource leak. "
|
|
903
|
+
"Resource not closed ⚠️"
|
|
904
|
+
),
|
|
905
|
+
"fix_suggestion": (
|
|
906
|
+
"Use 'with' statements for files and connections. "
|
|
907
|
+
"Explicitly close resources when done"
|
|
908
|
+
),
|
|
909
|
+
"tags": ["warning", "resource", "leak", "cleanup"],
|
|
910
|
+
"emoji": "⚠️"
|
|
911
|
+
},
|
|
912
|
+
|
|
913
|
+
# =========================================================================
|
|
914
|
+
# EXCEPTION GROUP (Python 3.11+)
|
|
915
|
+
# =========================================================================
|
|
916
|
+
"ExceptionGroup": {
|
|
917
|
+
"simple_explanation": (
|
|
918
|
+
"Multiple exceptions occurred at the same time. "
|
|
919
|
+
"This groups several errors together. "
|
|
920
|
+
"Multiple errors happened 🎯"
|
|
921
|
+
),
|
|
922
|
+
"fix_suggestion": (
|
|
923
|
+
"Handle each exception in the group individually. "
|
|
924
|
+
"Use except* syntax (Python 3.11+) to catch specific types"
|
|
925
|
+
),
|
|
926
|
+
"tags": ["group", "multiple", "concurrent", "python311"],
|
|
927
|
+
"emoji": "🎯"
|
|
928
|
+
},
|
|
929
|
+
|
|
930
|
+
"BaseExceptionGroup": {
|
|
931
|
+
"simple_explanation": (
|
|
932
|
+
"Multiple base exceptions occurred simultaneously. "
|
|
933
|
+
"Like ExceptionGroup but can include system exits and interrupts. "
|
|
934
|
+
"Multiple base errors 🎯"
|
|
935
|
+
),
|
|
936
|
+
"fix_suggestion": (
|
|
937
|
+
"Use except* syntax to handle each exception type. "
|
|
938
|
+
"Be careful with system exits in groups"
|
|
939
|
+
),
|
|
940
|
+
"tags": ["group", "multiple", "base", "python311"],
|
|
941
|
+
"emoji": "🎯"
|
|
942
|
+
},
|
|
943
|
+
|
|
944
|
+
# =========================================================================
|
|
945
|
+
# ENVIRONMENT ERROR (deprecated alias)
|
|
946
|
+
# =========================================================================
|
|
947
|
+
"EnvironmentError": {
|
|
948
|
+
"simple_explanation": (
|
|
949
|
+
"An environment-related error (old alias for OSError). "
|
|
950
|
+
"This is deprecated - use OSError instead. "
|
|
951
|
+
"Environment problem 🌍"
|
|
952
|
+
),
|
|
953
|
+
"fix_suggestion": (
|
|
954
|
+
"Catch OSError instead. This is kept for backward compatibility"
|
|
955
|
+
),
|
|
956
|
+
"tags": ["environment", "deprecated", "os", "legacy"],
|
|
957
|
+
"emoji": "🌍"
|
|
958
|
+
},
|
|
959
|
+
|
|
960
|
+
# =========================================================================
|
|
961
|
+
# WINDOWS ERROR (Windows-specific)
|
|
962
|
+
# =========================================================================
|
|
963
|
+
"WindowsError": {
|
|
964
|
+
"simple_explanation": (
|
|
965
|
+
"A Windows-specific system error occurred. "
|
|
966
|
+
"This is an alias for OSError on Windows. "
|
|
967
|
+
"Windows system error 🪟"
|
|
968
|
+
),
|
|
969
|
+
"fix_suggestion": (
|
|
970
|
+
"Check Windows-specific error code, verify system permissions, "
|
|
971
|
+
"or check Windows documentation"
|
|
972
|
+
),
|
|
973
|
+
"tags": ["windows", "os", "system", "platform"],
|
|
974
|
+
"emoji": "🪟"
|
|
975
|
+
},
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
def get_exception_info(exception_name: str) -> dict:
|
|
980
|
+
"""
|
|
981
|
+
Get exception information from EXCEPTION_MAP.
|
|
982
|
+
|
|
983
|
+
Args:
|
|
984
|
+
exception_name: Name of the exception class (e.g., 'ValueError')
|
|
985
|
+
|
|
986
|
+
Returns:
|
|
987
|
+
Dictionary with explanation, fix_suggestion, tags, and emoji.
|
|
988
|
+
Returns fallback info if exception not found.
|
|
989
|
+
"""
|
|
990
|
+
if exception_name in EXCEPTION_MAP:
|
|
991
|
+
return EXCEPTION_MAP[exception_name]
|
|
992
|
+
|
|
993
|
+
# Fallback for unknown exceptions
|
|
994
|
+
return {
|
|
995
|
+
"simple_explanation": (
|
|
996
|
+
"An error occurred that we don't have detailed info about yet. "
|
|
997
|
+
"Something unexpected went wrong in your code. "
|
|
998
|
+
"Check the error name for clues ❓"
|
|
999
|
+
),
|
|
1000
|
+
"fix_suggestion": (
|
|
1001
|
+
"Read the full error message carefully, search online for the error name, "
|
|
1002
|
+
"or check the documentation for what you're trying to do"
|
|
1003
|
+
),
|
|
1004
|
+
"tags": ["unknown", "general", "unhandled"],
|
|
1005
|
+
"emoji": "❓"
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
|
|
1009
|
+
def list_all_exceptions() -> list:
|
|
1010
|
+
"""Return sorted list of all exception names in the mapping."""
|
|
1011
|
+
return sorted(EXCEPTION_MAP.keys())
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
def search_exceptions_by_tag(tag: str) -> list:
|
|
1015
|
+
"""
|
|
1016
|
+
Find all exceptions with a specific tag.
|
|
1017
|
+
|
|
1018
|
+
Args:
|
|
1019
|
+
tag: Tag to search for (e.g., 'syntax', 'file', 'network')
|
|
1020
|
+
|
|
1021
|
+
Returns:
|
|
1022
|
+
List of exception names matching the tag
|
|
1023
|
+
"""
|
|
1024
|
+
results = []
|
|
1025
|
+
for exc_name, exc_info in EXCEPTION_MAP.items():
|
|
1026
|
+
if tag.lower() in [t.lower() for t in exc_info.get("tags", [])]:
|
|
1027
|
+
results.append(exc_name)
|
|
1028
|
+
return sorted(results)
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
# Statistics about the mapping
|
|
1032
|
+
TOTAL_EXCEPTIONS = len(EXCEPTION_MAP)
|
|
1033
|
+
ALL_TAGS = sorted(set(
|
|
1034
|
+
tag
|
|
1035
|
+
for exc_info in EXCEPTION_MAP.values()
|
|
1036
|
+
for tag in exc_info.get("tags", [])
|
|
1037
|
+
))
|