Skip to content
This repository has been 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

Open
mileswwatkins opened this issue Jun 21, 2018 · 0 comments
Open

Comments

@mileswwatkins
Copy link
Contributor

mileswwatkins commented Jun 21, 2018

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant