mirror of
https://github.com/frappe/gunicorn.git
synced 2026-07-05 04:01:29 +08:00
fix: use proper exception chaining with 'raise from' in glogging.py
Use 'raise X from e' syntax instead of just 'raise X' when wrapping
exceptions. This provides more accurate exception chaining messages
("The above exception was the direct cause of" vs "During handling of").
Closes #2360
This commit is contained in:
parent
33e5337395
commit
a182066bea
@ -237,7 +237,7 @@ class Logger:
|
||||
ValueError,
|
||||
TypeError
|
||||
) as exc:
|
||||
raise RuntimeError(str(exc))
|
||||
raise RuntimeError(str(exc)) from exc
|
||||
elif cfg.logconfig_json:
|
||||
config = CONFIG_DEFAULTS.copy()
|
||||
if os.path.exists(cfg.logconfig_json):
|
||||
@ -252,7 +252,7 @@ class Logger:
|
||||
ValueError,
|
||||
TypeError
|
||||
) as exc:
|
||||
raise RuntimeError(str(exc))
|
||||
raise RuntimeError(str(exc)) from exc
|
||||
elif cfg.logconfig:
|
||||
if os.path.exists(cfg.logconfig):
|
||||
defaults = CONFIG_DEFAULTS.copy()
|
||||
@ -442,8 +442,8 @@ class Logger:
|
||||
# syslog facility
|
||||
try:
|
||||
facility = SYSLOG_FACILITIES[cfg.syslog_facility.lower()]
|
||||
except KeyError:
|
||||
raise RuntimeError("unknown facility name")
|
||||
except KeyError as exc:
|
||||
raise RuntimeError("unknown facility name") from exc
|
||||
|
||||
# parse syslog address
|
||||
socktype, addr = parse_syslog_address(cfg.syslog_addr)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user