Skip to content

Commit

Permalink
Merge pull request #140 from scrapinghub/Gallaecio-patch-1
Browse files Browse the repository at this point in the history
parse_job_key: Improve ValueError messages
  • Loading branch information
vshlapakov committed Dec 12, 2019
2 parents 32b7c04 + 3441c1a commit 872665b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions scrapinghub/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ def parse_job_key(job_key):
elif isinstance(job_key, six.string_types):
parts = job_key.split('/')
else:
raise ValueError("Job key should be a string or a tuple")
raise ValueError("Job key should be a string or a tuple, got {}: {}"
.format(type(job_key), repr(job_key)))
if len(parts) != 3:
raise ValueError(
"Job key should consist of project_id/spider_id/job_id")
"Job key should consist of project_id/spider_id/job_id, got {}"
.format(repr(job_key)))
try:
list(map(int, parts))
except ValueError:
raise ValueError("Job key parts should be integers")
raise ValueError("Job key parts should be integers, got {}"
.format(repr(job_key)))
return JobKey(*map(str, parts))


Expand Down

0 comments on commit 872665b

Please sign in to comment.