From 1fcb2700bf9906fec934d96d49b11ad2bf6c50c9 Mon Sep 17 00:00:00 2001 From: Serge Smertin <259697+nfx@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:46:26 +0100 Subject: [PATCH] Rename `databricks.sdk.errors.mapping` to `databricks.sdk.errors.platform` (#522) `databricks.sdk.errors.mapping.ResourceDoesNotExist: Path (/Users/serge.smertin@databricks.com/.vMj0/state.json) doesn't exist.` is not as clear as `databricks.sdk.errors.platform.ResourceDoesNotExist: ...`, where it's obvious errors are coming from the Databricks Platform. image --- .codegen.json | 2 +- databricks/sdk/errors/__init__.py | 2 +- databricks/sdk/errors/mapper.py | 10 +++++----- databricks/sdk/errors/{mapping.py => platform.py} | 0 4 files changed, 7 insertions(+), 7 deletions(-) rename databricks/sdk/errors/{mapping.py => platform.py} (100%) diff --git a/.codegen.json b/.codegen.json index 17df6fd8f..c190dc416 100644 --- a/.codegen.json +++ b/.codegen.json @@ -8,7 +8,7 @@ }, "batch": { ".codegen/__init__.py.tmpl": "databricks/sdk/__init__.py", - ".codegen/error_mapping.py.tmpl": "databricks/sdk/errors/mapping.py" + ".codegen/error_mapping.py.tmpl": "databricks/sdk/errors/platform.py" }, "samples": { ".codegen/example.py.tmpl": "examples/{{.Service.SnakeName}}/{{.Method.SnakeName}}_{{.SnakeName}}.py" diff --git a/databricks/sdk/errors/__init__.py b/databricks/sdk/errors/__init__.py index a12c3cfe9..d6ea05cc7 100644 --- a/databricks/sdk/errors/__init__.py +++ b/databricks/sdk/errors/__init__.py @@ -1,4 +1,4 @@ from .base import DatabricksError, ErrorDetail from .mapper import error_mapper -from .mapping import * +from .platform import * from .sdk import * diff --git a/databricks/sdk/errors/mapper.py b/databricks/sdk/errors/mapper.py index dd47b34d0..225be818b 100644 --- a/databricks/sdk/errors/mapper.py +++ b/databricks/sdk/errors/mapper.py @@ -1,18 +1,18 @@ -from databricks.sdk.errors import mapping +from databricks.sdk.errors import platform 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: + if error_code in platform.ERROR_CODE_MAPPING: # more specific error codes override more generic HTTP status codes - return mapping.ERROR_CODE_MAPPING[error_code](**raw) + return platform.ERROR_CODE_MAPPING[error_code](**raw) - if status_code in mapping.STATUS_CODE_MAPPING: + if status_code in platform.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) + return platform.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. diff --git a/databricks/sdk/errors/mapping.py b/databricks/sdk/errors/platform.py similarity index 100% rename from databricks/sdk/errors/mapping.py rename to databricks/sdk/errors/platform.py