-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add concrete errors to public API #36
Conversation
This commit adds four concrete errors to the public API and ensures that all returned errors are either instances of those concrete types OR are wrapped by more descriptive errors. The four error types are: 1. ClientError: for all errors that are the result of the client making semantic error in their request 2. ServerError: for all the (uncommon) cases where the server returns data that is somehow and unexpectedly invalid. 3. APIError: for any errors that occurs when interacting with the SQL Admin API. These errors wrap the underlying google.golang.org/api/googleapi.Error types. 4. DialError: for any error that occurs when attempting to connect to a particular SQL instance. By providing concrete errors or wrapping concrete errors, we allow our clients to uses the errors.As API to possibly react differently to errors coming out of the dialer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High level thoughts:
DialError
seems good. Should there be a high level error to capture anything during a refresh (e.g. RefreshError
)? It seems like it might be useful between differentiating "the dial didn't' work" and "this refresh operation wasn't successful".
I'm not sure I understand why APIError
and ServerError
are two different error types. Do I really care if the API returned a non 2xx code vs a bad response (or a response I couldn't parse)? Seems like differentiating isn't useful.
Also, use initializers everywhere for errors.
I've consolidated |
Could |
RefreshError seems better than ServerError |
Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>
Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>
This commit adds three concrete errors to the public API and ensures that
all returned errors are either instances of those concrete types OR are
wrapped by more descriptive errors.
The three error types are:
ConfigError: for all errors that are the result of the client making
a semantic error in their request
RefreshError: for all the (uncommon) cases where the server returns
data that is somehow and unexpectedly invalid.
DialError: for any error that occurs when interacting with the SQL
Admin API or when attempting to connect to a
particular SQL instance.
By providing concrete errors or wrapping concrete errors, we allow our
clients to uses the errors.As API to possibly react differently to
errors coming out of the dialer.
Fixes #37