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

context for hook errors #478

Merged
merged 2 commits into from
Jul 6, 2017
Merged
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
12 changes: 10 additions & 2 deletions dbt/node_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,18 @@ def run_hooks(cls, project, adapter, flat_graph, hook_type):
auto_begin=True)
adapter.commit_if_has_connection(profile, model_name)

@classmethod
def safe_run_hooks(cls, project, adapter, flat_graph, hook_type):
try:
cls.run_hooks(project, adapter, flat_graph, hook_type)
except dbt.exceptions.RuntimeException as e:
logger.info("Database error while running {}".format(hook_type))
raise

@classmethod
def before_run(cls, project, adapter, flat_graph):
cls.try_create_schema(project, adapter)
cls.run_hooks(project, adapter, flat_graph, RunHookType.Start)
cls.safe_run_hooks(project, adapter, flat_graph, RunHookType.Start)

@classmethod
def print_results_line(cls, results, execution_time):
Expand All @@ -270,7 +278,7 @@ def print_results_line(cls, results, execution_time):

@classmethod
def after_run(cls, project, adapter, results, flat_graph, elapsed):
cls.run_hooks(project, adapter, flat_graph, RunHookType.End)
cls.safe_run_hooks(project, adapter, flat_graph, RunHookType.End)
cls.print_results_line(results, elapsed)

def describe_node(self):
Expand Down