Skip to content
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

Rename exceptions #258

Merged
merged 7 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changes/unreleased/Under the Hood-20230110-100647.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Under the Hood
body: Rename exceptions to match dbt-core
time: 2023-01-10T10:06:47.570088-06:00
custom:
Author: emmyoop
Issue: "250"
PR: "258"
8 changes: 4 additions & 4 deletions dbt/adapters/redshift/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def fetch_cluster_credentials(
)

except boto_client.exceptions.ClientError as e:
raise dbt.exceptions.FailedToConnectException(
raise dbt.exceptions.FailedToConnectError(
"Unable to get temporary Redshift cluster credentials: {}".format(e)
)

Expand All @@ -127,7 +127,7 @@ def get_tmp_iam_cluster_credentials(cls, credentials):
iam_duration_s = credentials.iam_duration_seconds

if not cluster_id:
raise dbt.exceptions.FailedToConnectException(
raise dbt.exceptions.FailedToConnectError(
"'cluster_id' must be provided in profile if IAM " "authentication method selected"
)

Expand Down Expand Up @@ -156,7 +156,7 @@ def get_credentials(cls, credentials):
# this requirement is really annoying to encode into json schema,
# so validate it here
if credentials.password is None:
raise dbt.exceptions.FailedToConnectException(
raise dbt.exceptions.FailedToConnectError(
"'password' field is required for 'database' credentials"
)
return credentials
Expand All @@ -166,6 +166,6 @@ def get_credentials(cls, credentials):
return cls.get_tmp_iam_cluster_credentials(credentials)

else:
raise dbt.exceptions.FailedToConnectException(
raise dbt.exceptions.FailedToConnectError(
"Invalid 'method' in profile: '{}'".format(method)
)
6 changes: 3 additions & 3 deletions dbt/adapters/redshift/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def verify_database(self, database):
ra3_node = self.config.credentials.ra3_node

if database.lower() != expected.lower() and not ra3_node:
raise dbt.exceptions.NotImplementedException(
raise dbt.exceptions.NotImplementedError(
"Cross-db references allowed only in RA3.* node. ({} vs {})".format(
database, expected
)
Expand All @@ -85,8 +85,8 @@ def _get_catalog_schemas(self, manifest):
schemas = super(SQLAdapter, self)._get_catalog_schemas(manifest)
try:
return schemas.flatten(allow_multiple_databases=self.config.credentials.ra3_node)
except dbt.exceptions.RuntimeException as exc:
dbt.exceptions.raise_compiler_error(
except dbt.exceptions.DbtRuntimeError as exc:
raise dbt.exceptions.CompilationError(
"Cross-db references allowed only in {} RA3.* node. Got {}".format(
self.type(), exc.msg
)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def test_resolve_specific(config, manifest_extended, redshift_adapter, get_inclu
ctx['adapter'].config.dispatch

# macro_a exists, but default__macro_a and redshift__macro_a do not
with pytest.raises(dbt.exceptions.CompilationException):
with pytest.raises(dbt.exceptions.CompilationError):
ctx['adapter'].dispatch('macro_a').macro

# root namespace is always preferred, unless search order is explicitly defined in 'dispatch' config
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_redshift_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Plugin as RedshiftPlugin,
)
from dbt.clients import agate_helper
from dbt.exceptions import FailedToConnectException
from dbt.exceptions import FailedToConnectError

from .utils import config_from_parts_or_dicts, mock_connection, TestAdapterConversions, inject_adapter

Expand Down Expand Up @@ -115,7 +115,7 @@ def test_invalid_auth_method(self):
# we have to set method this way, otherwise it won't validate
self.config.credentials.method = 'badmethod'

with self.assertRaises(FailedToConnectException) as context:
with self.assertRaises(FailedToConnectError) as context:
with mock.patch.object(
RedshiftAdapter.ConnectionManager,
'fetch_cluster_credentials',
Expand All @@ -127,7 +127,7 @@ def test_invalid_auth_method(self):

def test_invalid_iam_no_cluster_id(self):
self.config.credentials = self.config.credentials.replace(method='iam')
with self.assertRaises(FailedToConnectException) as context:
with self.assertRaises(FailedToConnectError) as context:
with mock.patch.object(
RedshiftAdapter.ConnectionManager,
'fetch_cluster_credentials',
Expand Down