-
Notifications
You must be signed in to change notification settings - Fork 123
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
Introduce more specific exceptions, like NotFound
, AlreadyExists
, BadRequest
, PermissionDenied
, InternalError
, and others
#376
Merged
Commits on Oct 3, 2023
-
(RFC) Introduce more specific exceptions, like
NotFound
, `AlreadyEx……ists`, `BadRequest`, `PermissionDenied`, `InternalError`, and others Improve the ergonomics of SDK, where instead of `except DatabricksError as err: if err.error_code != 'NOT_FOUND': raise err else: do_stuff()` we could do `except NotFound: do_stuff()`. Additionally, it'll make it easier to read stack traces, as they will contain specific exception class name. # First principles - do not override `builtins.NotImplemented` for `NOT_IMPLEMENTED` error code - assume that platform error_code/HTTP status code mapping is not perfect and in the state of transition - we do represent reasonable subset of error codes as specific exceptions ## Open questions ### HTTP Status Codes vs Error Codes 1. Mix between status codes and error codes (preferred) 2. Rely only on HTTP status codes 3. Rely only on `error_code`'s One example is `BAD_REQUEST` error code that maps onto HTTP 400 and to `except BadRequest as err` catch clause. But `MALFORMED_REQUEST`, `INVALID_STATE`, and `UNPARSEABLE_HTTP_ERROR` do also map to HTTP 400. So the proposal is to remap the MALFORMED_REQUEST to `BadRequest` exception. Another corner-case is UC: - 'METASTORE_DOES_NOT_EXIST': NotFound, - 'DAC_DOES_NOT_EXIST': NotFound, - 'CATALOG_DOES_NOT_EXIST': NotFound, - 'SCHEMA_DOES_NOT_EXIST': NotFound, - 'TABLE_DOES_NOT_EXIST': NotFound, - 'SHARE_DOES_NOT_EXIST': NotFound, - 'RECIPIENT_DOES_NOT_EXIST': NotFound, - 'STORAGE_CREDENTIAL_DOES_NOT_EXIST': NotFound, - 'EXTERNAL_LOCATION_DOES_NOT_EXIST': NotFound, - 'PRINCIPAL_DOES_NOT_EXIST': NotFound, - 'PROVIDER_DOES_NOT_EXIST': NotFound, ### Naming conflict resolution We have three sources of naming: - `error_code` - HTTP Status - Python builtin exceptions We still have to define which name takes the precedence.
Configuration menu - View commit details
-
Copy full SHA for 244de7c - Browse repository at this point
Copy the full SHA 244de7cView commit details
Commits on Oct 10, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 0fb81ee - Browse repository at this point
Copy the full SHA 0fb81eeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 80b728d - Browse repository at this point
Copy the full SHA 80b728dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0021809 - Browse repository at this point
Copy the full SHA 0021809View commit details -
Configuration menu - View commit details
-
Copy full SHA for ea598cc - Browse repository at this point
Copy the full SHA ea598ccView commit details
Commits on Nov 10, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 52ff2ea - Browse repository at this point
Copy the full SHA 52ff2eaView commit details -
Configuration menu - View commit details
-
Copy full SHA for 47bd23e - Browse repository at this point
Copy the full SHA 47bd23eView commit details
Commits on Nov 13, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 7294c0d - Browse repository at this point
Copy the full SHA 7294c0dView commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.