Skip to content

Commit e58b588

Browse files
alwaysintrebleNewSoupVi
authored and
James Schurig
committed
Options: Add an OptionError to specify bad options caused the failure (ArchipelagoMW#2343)
* Options: Add an OptionError to specify bad options caused the failure * inherit from ValueError instead of RuntimeError since this error should be thrown via bad input --------- Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
1 parent 667c3a7 commit e58b588

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Generate.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def roll_meta_option(option_key, game: str, category_dict: Dict) -> Any:
353353
if options[option_key].supports_weighting:
354354
return get_choice(option_key, category_dict)
355355
return category_dict[option_key]
356-
raise Exception(f"Error generating meta option {option_key} for {game}.")
356+
raise Options.OptionError(f"Error generating meta option {option_key} for {game}.")
357357

358358

359359
def roll_linked_options(weights: dict) -> dict:
@@ -417,7 +417,7 @@ def handle_option(ret: argparse.Namespace, game_weights: dict, option_key: str,
417417
player_option = option.from_any(get_choice(option_key, game_weights))
418418
setattr(ret, option_key, player_option)
419419
except Exception as e:
420-
raise Exception(f"Error generating option {option_key} in {ret.game}") from e
420+
raise Options.OptionError(f"Error generating option {option_key} in {ret.game}") from e
421421
else:
422422
player_option.verify(AutoWorldRegister.world_types[ret.game], ret.name, plando_options)
423423
else:

Options.py

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
import pathlib
2222

2323

24+
class OptionError(ValueError):
25+
pass
26+
27+
2428
class Visibility(enum.IntFlag):
2529
none = 0b0000
2630
template = 0b0001

0 commit comments

Comments
 (0)