Best Python code snippet using avocado_python
error_handler.py
Source:error_handler.py
...32 output.write_line(f'Failed to write to log at {log_path}')33 log = sys.stdout.buffer34 _log_line = functools.partial(output.write_line, stream=log)35 _log_line_b = functools.partial(output.write_line_b, stream=log)36 _log_line('### version information')37 _log_line()38 _log_line('```')39 _log_line(f'pre-commit version: {C.VERSION}')40 _log_line(f'git --version: {git_version}')41 _log_line('sys.version:')42 for line in sys.version.splitlines():43 _log_line(f' {line}')44 _log_line(f'sys.executable: {sys.executable}')45 _log_line(f'os.name: {os.name}')46 _log_line(f'sys.platform: {sys.platform}')47 _log_line('```')48 _log_line()49 _log_line('### error information')50 _log_line()51 _log_line('```')52 _log_line_b(error_msg)53 _log_line('```')54 _log_line()55 _log_line('```')56 _log_line(formatted.rstrip())57 _log_line('```')58 raise SystemExit(ret_code)59@contextlib.contextmanager60def error_handler() -> Generator[None, None, None]:61 try:62 yield63 except (Exception, KeyboardInterrupt) as e:64 if isinstance(e, FatalError):65 msg, ret_code = 'An error has occurred', 166 elif isinstance(e, KeyboardInterrupt):67 msg, ret_code = 'Interrupted (^C)', 13068 else:69 msg, ret_code = 'An unexpected error has occurred', 3...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!