-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
47 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .base import DatabricksError, ErrorDetail | ||
from .mapper import error_mapper | ||
from .mapping import * | ||
from .sdk import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from databricks.sdk.errors import mapping | ||
from databricks.sdk.errors.base import DatabricksError | ||
|
||
|
||
def error_mapper(status_code: int, raw: dict) -> DatabricksError: | ||
error_code = raw.get('error_code', None) | ||
if error_code in mapping.ERROR_CODE_MAPPING: | ||
# more specific error codes override more generic HTTP status codes | ||
return mapping.ERROR_CODE_MAPPING[error_code](**raw) | ||
|
||
if status_code in mapping.STATUS_CODE_MAPPING: | ||
# more generic HTTP status codes matched after more specific error codes, | ||
# where there's a default exception class per HTTP status code, and we do | ||
# rely on Databricks platform exception mapper to do the right thing. | ||
return mapping.STATUS_CODE_MAPPING[status_code](**raw) | ||
|
||
# backwards-compatible error creation for cases like using older versions of | ||
# the SDK on way never releases of the platform. | ||
return DatabricksError(**raw) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters