Skip to content

Better error message for wrong battle sprite size #343

Description

@PhoenixBound

If you create an enemy sprite that's 32 pixels by 33 pixels wide, you'll get a cryptic error message:

Compiling Enemies...
Traceback (most recent call last):
  File "coilsnake\ui\gui.py", line 304, in _do_compile_help
  File "coilsnake\ui\common.py", line 162, in compile_project
  File "coilsnake\modules\eb\EnemyModule.py", line 103, in write_to_rom
  File "coilsnake\model\eb\sprites.py", line 78, in size
ValueError: (32, 33) is not in list

(32, 33) is not in list

with only the last message being visible outside of debug mode. People who get this message often don't understand what the error message is referring to or don't remember that they edited a battle sprite in the first place, making it very difficult to discover the cause and find the offending sprite.

It's kind of awkward that the issue is being recognized so late into compilation (after reading from the project has already completed and we're trying to write to the ROM). I guess the module doesn't verify things to that extent in the read_* methods? But putting that aside, this would be one way of doing a minimal fix:

  • EbBattleSprite.size() in coilsnake.model.eb.sprites should probably be updated not to assume that the width and height values form a valid key to BATTLE_SPRITE_SIZES. Instead, it should use the find method and raise and explicit exception saying "Invalid image size {}x{}" or similar.
  • The for loop over all battle sprites in write_to_rom should wrap the loop body in a try/except and say "Error when writing battle sprite #{} to the ROM" or similar, so that the error message includes the sprite number where things went wrong

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions