Improve error handling for invalid date input#132
Merged
larose merged 11 commits intolarose:masterfrom Dec 31, 2025
Merged
Conversation
larose
reviewed
Dec 15, 2025
Owner
larose
left a comment
There was a problem hiding this comment.
Thanks for the PR! It looks good overall, but I've left a few comments.
Could you also add a single integration test to confirm that UttError is handled at the top level and formats a clean message without a stack trace? (We only need to do this for one case)
Also, please add yourself to the contributors list in the readme.
UttError is independent of entries.py and can be used in other contexts, so it belongs in its own file for better reusability.
Replace legacy %s/%d formatting with modern f-strings for better readability and consistency.
Verify that UttError displays a clean error message without a stack trace when an invalid date is provided to the report command.
Move UttError from utt/components/utt_error.py to utt/exceptions.py following Python conventions (requests, boto3, etc.) for placing exceptions at the package root.
…g None Simplifies error handling by having a single path for parsing exceptions. EntryParser.parse now returns Entry (not Optional[Entry]) and raises ValueError for any unparseable input.
larose
reviewed
Dec 22, 2025
Owner
larose
left a comment
There was a problem hiding this comment.
Thanks, this looks good overall and should be the last round of feedback. I left a minor comment (plus one I apparently forgot to submit in my first review).
Owner
|
@loganthomas some checks are failing, I'll merged once they are fixed. |
Owner
|
Thank you for your contribution @loganthomas! This is now available in version 1.32. Apologies for the delay. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve error messages for invalid dates
Closes #94
Summary
When utt encounters invalid date input—either from command-line arguments or from entries in the log file—it now displays a user-friendly error message instead of a Python traceback.
Problem
Previously, invalid date usage produced unhelpful tracebacks:
Solution
Added a simple
UttErrorexception class for user-facing errors. Invalid dates now produce clean, actionable messages.Examples
Invalid date argument
Invalid month argument
Invalid date in log file
Entries not in chronological order
Changes
utt/components/entries.py: AddedUttErrorexception class; catchValueErrorfrom date parsing and convert to user-friendly errorutt/components/report_args.py: Wrapstrptimecalls to raiseUttErroron invalid inpututt/__main__.py: CatchUttErrorat top level and print clean error messageTests
Added tests for the new error handling:
test_invalid_date_raises_utt_errortest_invalid_month_raises_utt_errortest_invalid_date_raises_value_error(for log file entries)