mitmproxy/mitmproxy/addons
Nicolas Jeker d72b92bdff
Show exception and stack trace on startup errors (#6491)
#### Description

It's hard to debug errors raised in addon scripts during startup as only
a generic message is output on the console. Using logger.format() to
format errors that occurred during startup instead of only displaying
the LogRecord.msg improves the output if an exception is present by
showing the stack trace. An additional newline was added for better
readability.

Comparison with the load_error.py test script, before:

    $ mitmproxy -s test/mitmproxy/data/addonscripts/load_error.py
    Error logged during startup: Addon error:

After:

    $ mitmproxy -s test/mitmproxy/data/addonscripts/load_error.py
    Error logged during startup:
    Addon error:
    Traceback (most recent call last):
File "test/mitmproxy/data/addonscripts/load_error.py", line 2, in load
        raise ValueError()
    ValueError

Relates to issue #5935 and PR #6020

#### Checklist

 - [ ] I have updated tests where applicable.
- I think the value of extending `test_errorcheck.py` for this behavior
is low and tightly couples the test to `logger.format()`
 - [ ] I have added an entry to the CHANGELOG.
- #6020 didn't introduce a changelog entry, so I figured this won't need
one either
2023-11-18 10:03:50 +01:00
..
onboardingapp Make mitmweb use relative paths to connect to its resources. (#6411) 2023-10-19 14:10:26 -07:00
__init__.py add save HAR addon (#6368) 2023-09-24 13:51:22 +00:00
anticache.py
anticomp.py
asgiapp.py improve how we log tracebacks (#6295) 2023-08-02 21:53:43 +00:00
block.py
blocklist.py [autofix.ci] apply automated fixes 2022-11-29 13:28:41 +00:00
browser.py [autofix.ci] apply automated fixes 2023-02-27 08:37:11 +01:00
clientplayback.py improve how we log tracebacks (#6295) 2023-08-02 21:53:43 +00:00
command_history.py [autofix.ci] apply automated fixes 2022-11-29 13:28:41 +00:00
comment.py [autofix.ci] apply automated fixes 2022-11-29 13:28:41 +00:00
core.py Migrate to ruff (#6433) 2023-10-31 16:03:53 +01:00
cut.py [autofix.ci] apply automated fixes 2023-02-27 08:37:11 +01:00
disable_h2c.py
dns_resolver.py [autofix.ci] apply automated fixes 2023-02-27 08:37:11 +01:00
dumper.py Migrate to ruff (#6433) 2023-10-31 16:03:53 +01:00
errorcheck.py Show exception and stack trace on startup errors (#6491) 2023-11-18 10:03:50 +01:00
eventstore.py [autofix.ci] apply automated fixes 2023-02-27 08:37:11 +01:00
export.py [autofix.ci] apply automated fixes 2023-02-27 08:37:11 +01:00
intercept.py [autofix.ci] apply automated fixes 2023-02-27 08:37:11 +01:00
keepserving.py fix usage of asyncio.create_task (#5928) 2023-02-13 21:45:02 +00:00
maplocal.py [autofix.ci] apply automated fixes 2022-11-29 13:28:41 +00:00
mapremote.py [autofix.ci] apply automated fixes 2022-11-29 13:28:41 +00:00
modifybody.py [autofix.ci] apply automated fixes 2022-11-29 13:28:41 +00:00
modifyheaders.py [autofix.ci] apply automated fixes 2022-11-29 13:28:41 +00:00
next_layer.py fix #5972 (#5982) 2023-03-09 15:48:26 +00:00
onboarding.py [autofix.ci] apply automated fixes 2022-11-29 13:28:41 +00:00
proxyauth.py fix #6426 - Optimize LDAP Proxy Auth (#6428) 2023-10-31 12:52:21 +00:00
proxyserver.py use client.id as connection id where possible (#6372) 2023-09-18 23:17:46 +00:00
readfile.py fix usage of asyncio.create_task (#5928) 2023-02-13 21:45:02 +00:00
save.py add save HAR addon (#6368) 2023-09-24 13:51:22 +00:00
savehar.py Fix case that causes corrupt har files to be written (#6459) 2023-11-06 07:31:28 -08:00
script.py improve how we log tracebacks (#6295) 2023-08-02 21:53:43 +00:00
server_side_events.py
serverplayback.py Add option to return various status codes rather than killing during server replay (#6465) 2023-11-08 11:12:44 +01:00
stickyauth.py [autofix.ci] apply automated fixes 2022-11-29 13:28:41 +00:00
stickycookie.py [autofix.ci] apply automated fixes 2023-02-27 08:37:11 +01:00
termlog.py fix usage of asyncio.create_task (#5928) 2023-02-13 21:45:02 +00:00
tlsconfig.py Migrate to ruff (#6433) 2023-10-31 16:03:53 +01:00
upstream_auth.py [autofix.ci] apply automated fixes 2023-02-27 08:37:11 +01:00
view.py Migrate to ruff (#6433) 2023-10-31 16:03:53 +01:00