More informative KeyError messages in converter #1344
Labels
assets
Involved with assets (images, sounds, ...)
good first issue
Simple thing, suitable for newcomers
improvement
Enhancement of an existing component
python
Done in Python code
Projects
Required skills: Python
Difficulty: Medium
In AoE2's
.datformat most associations and assignments of properties are done by IDs (e.g. unit has ability with ID X). The openage converter uses these IDs to lookup the associated openage API property and then map the values from AoE2's.datstructure to the corresponding API object's member values. In short, every property from AoE2 needs to be manually mapped to an openage API property. As such, most of the runtime errors are actually lookup errors (usually Python'sKeyError) that occur when an AoE2 property was not mapped to an openage API property.The goal of this task is to make these errors more informative by catching the generic
KeyErrorfrom Python and re-raising it with a better message. For example, we can improve the error message by specifying:Example
generic message:
better message:
Use try-except statement where these lookups could be thrown. Remember to use
raise ... fromto preserve the stack trace of the initialKeyError.Further reading:
The text was updated successfully, but these errors were encountered: