|
75 | 75 | DEFAULT_HEIGHT = 25 |
76 | 76 |
|
77 | 77 |
|
78 | | -class PasswordFileError(Exception): |
79 | | - """Base exception for errors related to reading password files.""" |
80 | | - |
81 | | - |
82 | 78 | class MyCli: |
83 | 79 | default_prompt = "\\t \\u@\\h:\\d> " |
84 | 80 | default_prompt_splitln = "\\u@\\h\\n(\\t):\\d>" |
@@ -561,13 +557,17 @@ def get_password_from_file(self, password_file: str) -> str: |
561 | 557 | password = fp.readline().strip() |
562 | 558 | return password |
563 | 559 | except FileNotFoundError: |
564 | | - raise PasswordFileError(f"Password file '{password_file}' not found") from None |
| 560 | + click.secho(f"Password file '{password_file}' not found", err=True, fg="red") |
| 561 | + sys.exit(1) |
565 | 562 | except PermissionError: |
566 | | - raise PasswordFileError(f"Permission denied reading password file '{password_file}'") from None |
| 563 | + click.secho(f"Permission denied reading password file '{password_file}'", err=True, fg="red") |
| 564 | + sys.exit(1) |
567 | 565 | except IsADirectoryError: |
568 | | - raise PasswordFileError(f"Path '{password_file}' is a directory, not a file") from None |
| 566 | + click.secho(f"Path '{password_file}' is a directory, not a file", err=True, fg="red") |
| 567 | + sys.exit(1) |
569 | 568 | except Exception as e: |
570 | | - raise PasswordFileError(f"Error reading password file '{password_file}': {str(e)}") from None |
| 569 | + click.secho(f"Error reading password file '{password_file}': {str(e)}", err=True, fg="red") |
| 570 | + sys.exit(1) |
571 | 571 |
|
572 | 572 | def handle_editor_command(self, text: str) -> str: |
573 | 573 | r"""Editor command is any query that is prefixed or suffixed by a '\e'. |
|
0 commit comments