refactor: Simplify error handling in main function

This commit is contained in:
Paul Gauthier 2024-10-05 11:32:47 -07:00 committed by Paul Gauthier (aider)
parent 28fab9548b
commit e56df2391d

View file

@ -374,7 +374,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
print("For more information, refer to the aider documentation on configuration.")
return 1
else:
raise
raise e
if args.verbose:
print("Config files search order, if no --config:")
@ -386,24 +386,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
parser = get_parser(default_config_files, git_root)
try:
args, unknown = parser.parse_known_args(argv)
except AttributeError as e:
if "'bool' object has no attribute 'strip'" in str(e):
io.tool_error("Configuration error detected.")
io.tool_output("It seems you have 'yes:' in one of your configuration files.")
io.tool_output(
"Please replace 'yes:' with 'yes-always:' in the relevant .aider.conf.yml file."
)
io.tool_output("Configuration files are searched for in this order:")
for config_file in default_config_files:
io.tool_output(f" - {config_file}")
io.tool_output(
"For more information, refer to the aider documentation on configuration."
)
return 1
else:
raise
args, unknown = parser.parse_known_args(argv)
# Load the .env file specified in the arguments
loaded_dotenvs = load_dotenv_files(git_root, args.env_file, args.encoding)