diff options
author | Bryan Bishop <kanzure@gmail.com> | 2013-08-29 12:07:27 -0500 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2013-08-29 12:07:27 -0500 |
commit | 4c56a6c57a4c21acff5dcf5aa1c23138f0a743c3 (patch) | |
tree | b5c08a28e0895f35fee6bdc9d0390557e477f4a1 /pokemontools/preprocessor.py | |
parent | 0856dee10ad124a6f313492561ed1c2a2df74abd (diff) |
better KeyError exception message in preprocessor
Diffstat (limited to 'pokemontools/preprocessor.py')
-rw-r--r-- | pokemontools/preprocessor.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/pokemontools/preprocessor.py b/pokemontools/preprocessor.py index 0b099d3..e33cda7 100644 --- a/pokemontools/preprocessor.py +++ b/pokemontools/preprocessor.py @@ -5,7 +5,7 @@ Basic preprocessor for both pokecrystal and pokered. import sys -from extras.pokemontools.crystal import ( +from crystal import ( DataByteWordMacro, ) @@ -515,7 +515,19 @@ def macro_translator(macro, token, line, skippable_macros, show_original_lines=F try: param_type = macro.param_types[index - correction] except KeyError as exception: - raise Exception("line is: " + str(line) + " and macro is: " + str(macro)) + raise Exception( + "Got a KeyError on param_types. This usually happens when a " \ + "macro should have been skipped but wasn't. But there are also " \ + "other sources of this error.\n\n" \ + "line is: {line}\n" \ + "macro is: {macro}\n" \ + "error is: {error}\n" + .format( + line=line, + macro=macro, + error=exception, + ) + ) description = param_type["name"] param_klass = param_type["class"] byte_type = param_klass.byte_type # db or dw |