Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Improve error message in create_period_group()
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-gravgaard committed Aug 22, 2014
1 parent dfe76bd commit ab3a972
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions backdrop/core/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@


def create_period_group(doc, period):
if period.start_at_key not in doc or "_count" not in doc:
raise ValueError("Expected subgroup to have keys '_count'"
" and '{}'".format(period.start_at_key))
required = ['_count', period.start_at_key]
missing = [r for r in required if r not in doc]
if missing:
missing_text = ' and '.join(["'{}'".format(m) for m in missing])
raise ValueError('Expected record to have {}'.format(missing_text))

datum = doc.copy()

Expand Down

0 comments on commit ab3a972

Please sign in to comment.