Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught exception when date in wrong format #94

Open
ErykPiasecki07 opened this issue Feb 22, 2022 · 1 comment
Open

Uncaught exception when date in wrong format #94

ErykPiasecki07 opened this issue Feb 22, 2022 · 1 comment

Comments

@ErykPiasecki07
Copy link

If some utt functionality is used incorrectly, it provides quite a nice output like: "unrecognized argument" or something like this, however that's not the case with date usage in utt report.

To replicate simply run utt report 2022-02-20 or really anything that doesn't match %Y-%m-%d format.

The result will be:
Traceback (most recent call last): File "/opt/homebrew/bin/utt", line 8, in <module> sys.exit(main()) File "/opt/homebrew/lib/python3.9/site-packages/utt/__main__.py", line 9, in main main() File "/opt/homebrew/lib/python3.9/site-packages/utt/main.py", line 37, in main _v1._private.container[command.handler_class]() File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 68, in __getitem__ return self._pipeline.execute(dependency_type) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 80, in execute return self._stages.execute(key) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 95, in execute return self._middleware.execute(key, lambda: self._next_stage.execute(key)) File "/opt/homebrew/lib/python3.9/site-packages/cargo/middlewares.py", line 20, in execute return next_middleware() File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 95, in <lambda> return self._middleware.execute(key, lambda: self._next_stage.execute(key)) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 95, in execute return self._middleware.execute(key, lambda: self._next_stage.execute(key)) File "/opt/homebrew/lib/python3.9/site-packages/cargo/middlewares.py", line 54, in execute dependency_value = next_middleware() File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 95, in <lambda> return self._middleware.execute(key, lambda: self._next_stage.execute(key)) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 107, in execute return self._middleware.execute(key, self._should_never_be_called) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 28, in execute dependencies = self._resolve_dependencies(dependency_spec.dependency_types) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 34, in _resolve_dependencies return [ File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 35, in <listcomp> self._resolve_dependency(dependency_type) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 68, in __getitem__ return self._pipeline.execute(dependency_type) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 80, in execute return self._stages.execute(key) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 95, in execute return self._middleware.execute(key, lambda: self._next_stage.execute(key)) File "/opt/homebrew/lib/python3.9/site-packages/cargo/middlewares.py", line 20, in execute return next_middleware() File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 95, in <lambda> return self._middleware.execute(key, lambda: self._next_stage.execute(key)) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 95, in execute return self._middleware.execute(key, lambda: self._next_stage.execute(key)) File "/opt/homebrew/lib/python3.9/site-packages/cargo/middlewares.py", line 54, in execute dependency_value = next_middleware() File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 95, in <lambda> return self._middleware.execute(key, lambda: self._next_stage.execute(key)) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 107, in execute return self._middleware.execute(key, self._should_never_be_called) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 28, in execute dependencies = self._resolve_dependencies(dependency_spec.dependency_types) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 34, in _resolve_dependencies return [ File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 35, in <listcomp> self._resolve_dependency(dependency_type) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 68, in __getitem__ return self._pipeline.execute(dependency_type) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 80, in execute return self._stages.execute(key) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 95, in execute return self._middleware.execute(key, lambda: self._next_stage.execute(key)) File "/opt/homebrew/lib/python3.9/site-packages/cargo/middlewares.py", line 20, in execute return next_middleware() File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 95, in <lambda> return self._middleware.execute(key, lambda: self._next_stage.execute(key)) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 95, in execute return self._middleware.execute(key, lambda: self._next_stage.execute(key)) File "/opt/homebrew/lib/python3.9/site-packages/cargo/middlewares.py", line 54, in execute dependency_value = next_middleware() File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 95, in <lambda> return self._middleware.execute(key, lambda: self._next_stage.execute(key)) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 107, in execute return self._middleware.execute(key, self._should_never_be_called) File "/opt/homebrew/lib/python3.9/site-packages/cargo/_container.py", line 29, in execute return dependency_spec.instantiate(*dependencies) File "/opt/homebrew/lib/python3.9/site-packages/utt/components/report_args.py", line 257, in report_args report_range = parse_report_range_arguments( File "/opt/homebrew/lib/python3.9/site-packages/utt/components/report_args.py", line 44, in parse_report_range_arguments report_date = parse_date(today, unparsed_report_date) File "/opt/homebrew/lib/python3.9/site-packages/utt/components/report_args.py", line 70, in parse_date return parse_absolute_date(datestring) File "/opt/homebrew/lib/python3.9/site-packages/utt/components/report_args.py", line 74, in parse_absolute_date return datetime.datetime.strptime(datestring, "%Y-%m-%d").date() File "/opt/homebrew/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/_strptime.py", line 568, in _strptime_datetime tt, fraction, gmtoff_fraction = _strptime(data_string, format) File "/opt/homebrew/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/_strptime.py", line 349, in _strptime raise ValueError("time data %r does not match format %r" % ValueError: time data '324-4242-43' does not match format '%Y-%m-%d'

More desired behavior would be some user-friendly error message.

@larose
Copy link
Owner

larose commented Mar 26, 2022

Hi @ErykPiasecki07, the error message is indeed not user-friendly. If you are interested you can create a PR that addresses it (with tests).

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

No branches or pull requests

2 participants