Skip to content

Commit

Permalink
Raise ValueError where appropriate
Browse files Browse the repository at this point in the history
Invalid inputs usually raise a ValueError, AFAIK.
Generic Exceptions are kept for permission errors.

TODO: Maybe create a custom Exception for the
latter case.
  • Loading branch information
nothingface0 committed Oct 23, 2024
1 parent 8ec4ac4 commit c43b1c0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions runregistry/runregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def _execute_request_for_single_run(run_number, new_class):
)

if not isinstance(new_class, str):
raise Exception(f'Invalid input "{new_class}" for "new_class"')
raise ValueError(f'Invalid input "{new_class}" for "new_class"')
answers = []
# If just one int provided, make it into a list
if isinstance(run_numbers, int):
Expand All @@ -624,7 +624,7 @@ def _execute_request_for_single_run(run_number, new_class):
if isinstance(run_numbers, list):
for run_number in run_numbers:
if not isinstance(run_number, int):
raise Exception(
raise ValueError(
"Invalid run number value found in run_numbers. Please provide a list of numbers."
)
answer = _execute_request_for_single_run(run_number, new_class)
Expand All @@ -634,7 +634,7 @@ def _execute_request_for_single_run(run_number, new_class):
)
answers.append(answer.json())
else:
raise Exception(
raise ValueError(
'Invalid input for "run_numbers". Please provide a list of numbers.'
)
return answers

0 comments on commit c43b1c0

Please sign in to comment.