fix: replace 4 bare excepts with except Exception#74
Conversation
JiwaniZakir
left a comment
There was a problem hiding this comment.
The change from bare except: to except Exception: is a meaningful improvement, as bare excepts silently swallow SystemExit, KeyboardInterrupt, and GeneratorExit, which can make the process difficult to terminate cleanly. However, the underlying issue in most of these cases isn't just the exception type — it's that exceptions are being silenced entirely with no logging.
The trans_cookies in xianyu_utils.py is the most concerning: a malformed cookie silently continues with no indication of which cookie failed or why, making debugging cookie parsing issues unnecessarily difficult. Similarly, the except Exception: pass block in main.py around line 425 discards whatever error occurred during transaction detection without any trace in the logs.
The two except Exception blocks in json_serializer are slightly more defensible since they have fallback logic, but the second one (line 329) references e in the f-string (str(e)) from an outer except scope — worth verifying that e is actually in scope there, or this will raise a NameError at runtime in some Python versions. At minimum, these silent-catch sites should log at DEBUG or WARNING level so failures are observable in production.
Replace 4 bare
except:withexcept Exception:. Bareexcept:catchesKeyboardInterruptandSystemExit, masking real errors.