MCPcopy Index your code
hub / github.com/FSoft-AI4Code/CodeWiki / handle_error

Function handle_error

codewiki/cli/utils/errors.py:64–83  ·  view source on GitHub ↗

Handle errors and return appropriate exit code. Args: error: The exception to handle verbose: Whether to show detailed error information Returns: Exit code for the error

(error: Exception, verbose: bool = False)

Source from the content-addressed store, hash-verified

62
63
64def handle_error(error: Exception, verbose: bool = False) -> int:
65 """
66 Handle errors and return appropriate exit code.
67
68 Args:
69 error: The exception to handle
70 verbose: Whether to show detailed error information
71
72 Returns:
73 Exit code for the error
74 """
75 if isinstance(error, CodeWikiError):
76 click.secho(f"\n✗ Error: {error.message}", fg="red", err=True)
77 return error.exit_code
78 else:
79 click.secho(f"\n✗ Unexpected error: {error}", fg="red", err=True)
80 if verbose:
81 import traceback
82 click.echo(traceback.format_exc(), err=True)
83 return EXIT_GENERAL_ERROR
84
85
86def error_with_suggestion(message: str, suggestion: str, exit_code: int = EXIT_GENERAL_ERROR):

Callers 5

config_setFunction · 0.90
config_showFunction · 0.90
config_validateFunction · 0.90
config_agentFunction · 0.90
generate_commandFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected