Skip to content

Commit

Permalink
fix: add better exception handling for hook call
Browse files Browse the repository at this point in the history
  • Loading branch information
robcxyz committed Mar 19, 2023
1 parent 7e050ac commit 877c3fb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
3 changes: 3 additions & 0 deletions tackle/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def blocks_macro(context: 'Context'):
)
value = input_dict[indexed_key_path[-1]]

if value is None:
raise exceptions.HookCallException("Empty hook call found.", context=context)

for k, v in list(input_dict.items()):
if k == indexed_key_path[-1]:
nested_set(context.input_context, key_path, {arrow[0]: 'block'})
Expand Down
1 change: 1 addition & 0 deletions tests/parser/exceptions/empty-hook-call.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo->:
20 changes: 8 additions & 12 deletions tests/parser/test_parser_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
"""Test the input source part of the parser."""
import pytest

from tackle.exceptions import (
EmptyTackleFileException,
UnknownArgumentException,
UnknownSourceException,
HookParseException,
)
from tackle import exceptions

# from tackle import tackle
from tackle.cli import main

INPUT_SOURCES = [
# TODO: empty should now be running help screen
# ("empty-with-functions.yaml", EmptyTackleFileException),
("empty.yaml", EmptyTackleFileException),
("out-of-range-arg.yaml", UnknownArgumentException),
("non-existent.yaml", UnknownSourceException),
("hook-input-validation-error.yaml", HookParseException),
("function-input-validation-error.yaml", HookParseException),
# ("empty-with-functions.yaml", exceptions.EmptyTackleFileException),
("empty-hook-call.yaml", exceptions.HookCallException),
("empty.yaml", exceptions.EmptyTackleFileException),
("out-of-range-arg.yaml", exceptions.UnknownArgumentException),
("non-existent.yaml", exceptions.UnknownSourceException),
("hook-input-validation-error.yaml", exceptions.HookParseException),
("function-input-validation-error.yaml", exceptions.HookParseException),
]


Expand Down

0 comments on commit 877c3fb

Please sign in to comment.