Skip to content

Commit

Permalink
more tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
emmyoop committed Dec 13, 2022
1 parent ff230a7 commit 5231c2d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 deletions.
3 changes: 2 additions & 1 deletion core/dbt/config/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
DbtProjectError,
NonUniquePackageName,
RuntimeException,
UninstalledPackagesFound,
# UninstalledPackagesFound,
raise_compiler_error,
)
from dbt.events.functions import warn_or_error
from dbt.events.types import UnusedResourceConfigPath
Expand Down
51 changes: 20 additions & 31 deletions core/dbt/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,35 +686,24 @@ def get_message(self) -> str:
return msg


class GitCloningError(InternalException):
class BadSpecException(InternalException):
def __init__(self, repo, revision, error):
self.repo = repo
self.revision = revision
self.error = error
self.stderr = scrub_secrets(error.stderr.strip(), env_secrets())
super().__init__(msg=self.get_message())

def get_message(self) -> str:
stderr = self.error.stderr.strip()
if "usage: git" in stderr:
stderr = stderr.split("\nusage: git")[0]
if re.match("fatal: destination path '(.+)' already exists", stderr):
self.error.cmd = scrub_secrets(str(self.error.cmd), env_secrets())
raise self.error
msg = f"Error checking out spec='{self.revision}' for repo {self.repo}\n{self.stderr}"
return msg

msg = f"Error checking out spec='{self.revision}' for repo {self.repo}\n{stderr}"
return scrub_secrets(msg, env_secrets())

class GitCloningError(BadSpecException):
pass

class GitCheckoutError(InternalException):
def __init__(self, repo, revision, error):
self.repo = repo
self.revision = revision
self.stderr = error.stderr.strip()
super().__init__(msg=self.get_message())

def get_message(self) -> str:
msg = f"Error checking out spec='{self.revision}' for repo {self.repo}\n{self.stderr}"
return scrub_secrets(msg, env_secrets())
class GitCheckoutError(BadSpecException):
pass


class InvalidMaterializationArg(CompilationException):
Expand All @@ -728,20 +717,27 @@ def get_message(self) -> str:
return msg


class SymbolicLinkError(CompilationException):
def __init__(self):
class OperationException(CompilationException):
def __init__(self, operation_name):
self.operation_name = operation_name
super().__init__(msg=self.get_message())

def get_message(self) -> str:
msg = (
"dbt encountered an error when attempting to create a symbolic link. "
f"dbt encountered an error when attempting to create a {self.operation_name}. "
"If this error persists, please create an issue at: \n\n"
"https://github.com/dbt-labs/dbt-core"
)

return msg


class SymbolicLinkError(OperationException):
def __init__(self):
self.operation_name = "symbolic link"
super().__init__()


# context level exceptions


Expand Down Expand Up @@ -2196,22 +2192,15 @@ def get_relation_returned_multiple_results(kwargs, matches):


def system_error(operation_name):
# Note: This was converted for core to use SymbolicLinkError because it's the only way it was used. Maintaining flexibility here for now.
msg = (
f"dbt encountered an error when attempting to {operation_name}. "
"If this error persists, please create an issue at: \n\n"
"https://github.com/dbt-labs/dbt-core"
)
raise CompilationException(msg)
raise OperationException(operation_name)


def invalid_materialization_argument(name, argument):
raise InvalidMaterializationArg(name, argument)


def bad_package_spec(repo, spec, error_message):
msg = "Error checking out spec='{}' for repo {}\n{}".format(spec, repo, error_message)
raise InternalException(scrub_secrets(msg, env_secrets()))
BadSpecException(spec, repo, error_message)


def raise_git_cloning_error(error: CommandResultError) -> NoReturn:
Expand Down

0 comments on commit 5231c2d

Please sign in to comment.