msumit commented on pull request #19041: URL: https://github.com/apache/airflow/pull/19041#issuecomment-945700078
> I kind of feel like this is reinventing exceptions. It actually looks a lot like the [Result monad](https://en.wikipedia.org/wiki/Result_type) in some languages, or Go's `if err, result` construct. The idiomatic way to do this in Python is exceptions, so > > ```python > result, err = hook.test_connection() > if result: > ... # Success. > else: > print(f"failed with {err}") > ``` > > becomes > > ```python > try: > hook.check_connection() > except ConnectionFailure as e: > print(f"failed with {e}") > else: > ... # Success. > ``` Make sense.. modified the code.. -- 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]
