janw / podcast-archiver

Archive all your favorite podcasts
MIT License
118 stars 21 forks source link

UI issue: don't dumps stack on network error #178

Closed elharo closed 3 weeks ago

elharo commented 2 months ago

Sometimes a particular episode fails to download due to a network error outside the control of the program. This should be reported to the end user. However, this does not indicate a bug in the program and it should not dump an exception stack trace to the console.

TimeoutError: The read operation timed out                  

                    The above exception was the direct cause of                 
                    the following exception:                                    

                    ╭──── Traceback (most recent call last) ────╮               
                    │ /opt/homebrew/Cellar/podcast-archiver/1.5 │               
                    │ .0/libexec/lib/python3.12/site-packages/r │               
                    │ equests/adapters.py:667 in send           │               
                    │                                           │               
                    │   664 │   │   │   timeout = TimeoutSauce( │               
                    │   665 │   │                               │               
                    │   666 │   │   try:                        │               
                    │ ❱ 667 │   │   │   resp = conn.urlopen(    │               
                    │   668 │   │   │   │   method=request.meth │               
                    │   669 │   │   │   │   url=url,            │               
                    │   670 │   │   │   │   body=request.body,  │               
                    │                                           │  

This is a common antipattern in Python CLI programs. Not all exceptions are bugs, and non-bugs shouldn't dump stack traces.

elharo commented 2 months ago

At least one instance of this is here:

https://github.com/janw/podcast-archiver/blob/2aacf1cf20151289dac5b57a41bbe89ea4be4a5e/podcast_archiver/processor.py#L56

The except clause should report the error but not include the root exception

elharo commented 2 months ago

Or maybe disable the logger by default? Looks like user messages are printf'd instead.

janw commented 3 weeks ago

Fixed in #189.