Skip to content

Commit

Permalink
switch from assert to raise RuntimeError
Browse files Browse the repository at this point in the history
  • Loading branch information
w-e-w committed Jan 22, 2024
1 parent 96d6e3e commit be80b02
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ def set_named_arg(self, all_script_args, script_name, arg_elem_id, value):
"""
script = next((x for x in self.scripts if x.name == script_name), None)
if script is None:
assert False, f"script {script_name} not found"
raise RuntimeError(f"script {script_name} not found")

for i, control in enumerate(script.controls):
if arg_elem_id == control.elem_id:
Expand All @@ -965,7 +965,7 @@ def set_named_arg(self, all_script_args, script_name, arg_elem_id, value):
else:
return all_script_args[:index] + (value,) + all_script_args[index + 1:]

assert False, f"arg_elem_id {arg_elem_id} not found in script {script_name}"
raise RuntimeError(f"arg_elem_id {arg_elem_id} not found in script {script_name}")

def update_script_args(self, all_script_args, script_name, update_args):
"""Update a script's args in script_args
Expand All @@ -980,7 +980,7 @@ def update_script_args(self, all_script_args, script_name, update_args):
"""
script = next((x for x in self.scripts if x.name == script_name), None)
if script is None:
assert False, f"script {script_name} not found"
raise RuntimeError(f"script {script_name} not found")

assert len(update_args) == script.args_to - script.args_from, f"update_args length ({len(update_args)}) doesn't match {script_name} script's args length ({script.args_to - script.args_from})"

Expand All @@ -1002,7 +1002,7 @@ def get_script_args(self, all_script_args, script_name):
"""
script = next((x for x in self.scripts if x.name == script_name), None)
if script is None:
assert False, f"script {script_name} not found"
raise RuntimeError(f"script {script_name} not found")

return all_script_args[script.args_from:script.args_to]

Expand Down

0 comments on commit be80b02

Please sign in to comment.