Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Misleading/incorrect error message when using invalid AP_API_BASE_URL #331

@mileswwatkins

Description

@mileswwatkins

Just hit this for a while when setting up an app that depends on Elex, but where I'd injected an invalid AP_API_BASE_URL:

It ran: elex results --national-only --results-level ru --set-zero-counts 2016-11-08 > .data/results.csv (with an invalid AP_API_BASE_URL in os.environ)

And got in response: 2016-11-08 could not be recognized as a date.

This message is produced by the @require_date_argument decorator, presumably when it fails to find a date in the API's response.

try:
self.app.election.electiondate = parse_date(
self.app.pargs.date[0]
)
return fn(self)
except ValueError:
text = '{0} could not be recognized as a date.'
self.app.log.error(text.format(self.app.pargs.date[0]))
self.app.close(1)

This error message is misleading and frustrating; 2016-11-08 can indeed correctly get parsed by dateutil, and the error instead is that the field couldn't be found in the first place, I believe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions