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)
| 62 | |
| 63 | |
| 64 | def 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 | |
| 86 | def error_with_suggestion(message: str, suggestion: str, exit_code: int = EXIT_GENERAL_ERROR): |
no outgoing calls
no test coverage detected