You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/10/18 12:09:41 UTC
[GitHub] [airflow] msumit commented on pull request #19041: Add test_connection method for Snowflake
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org