MCPcopy
hub / github.com/mitmproxy/mitmproxy / shutdown_if_errored

Method shutdown_if_errored

mitmproxy/addons/errorcheck.py:28–46  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

26 self.logger.uninstall()
27
28 async def shutdown_if_errored(self):
29 # don't run immediately, wait for all logging tasks to finish.
30 await asyncio.sleep(0)
31 if self.logger.has_errored:
32 plural = "s" if len(self.logger.has_errored) > 1 else ""
33 if self.repeat_errors_on_stderr:
34 message = f"Error{plural} logged during startup:"
35 if vt_codes.ensure_supported(sys.stderr): # pragma: no cover
36 message = miniclick.style(message, fg="red")
37 details = "\n".join(
38 self.logger.format(r) for r in self.logger.has_errored
39 )
40 print(f"{message}\n{details}", file=sys.stderr)
41 else:
42 print(
43 f"Error{plural} logged during startup, exiting...", file=sys.stderr
44 )
45
46 sys.exit(1)
47
48
49class ErrorCheckHandler(log.MitmLogHandler):

Callers 4

test_no_errorFunction · 0.95
test_error_messageFunction · 0.95
runMethod · 0.80

Calls 4

styleMethod · 0.80
formatMethod · 0.80
exitMethod · 0.80
joinMethod · 0.45

Tested by 3

test_no_errorFunction · 0.76
test_error_messageFunction · 0.76