bugraoz93 commented on PR #49438:
URL: https://github.com/apache/airflow/pull/49438#issuecomment-2816226316

   > @bugraoz93 what are your thoughts? I felt this was the most minimal way of 
shorting the command call. If the credential check fails it exits early with 
the error
   > 
   > ```
   >  $airflowctl providers list
   > Failed to run due to  No credentials found in /root/.config/airflow
   > ```
   
   @aritra24 I first did this too, but printing an error to the user on api 
package is undesirable.
   How about adding a try catch here as a more generic call where we can manage 
multiple types of exceptions coming from packages that shouldn't print to the 
user but raise the exception, then we can catch a generic exception coming from 
decordator or something more broad than exceptions in commands for any method? 
This could be a more centric approach and prevent printing much on 
   
   `cli_parser.py`
   ``` Python
   def safe_call_action_command(function: Callable, args:Iterable[Arg]) -> None:
       try:
           function(args)
       except AirflowCtlNotFoundException as e:
           rich.print(f"Error: {e}")
   ```
   `__main__.py`
   ``` Python
   from airflowctl.ctl.cli_parser import safe_call_action_command
   
   
   def main():
       parser = cli_parser.get_parser()
       argcomplete.autocomplete(parser)
       args = parser.parse_args()
       safe_call_action_command(args.func, args=args)
   ```
   
   
https://github.com/apache/airflow/blob/113528cbb206bbf44d04282861ed96a789bcbfbd/airflow-ctl/src/airflowctl/__main__.py#L29-L33


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to