Skip to content

Commit

Permalink
add better error handling when solving intrinsic functions
Browse files Browse the repository at this point in the history
Previouly any error in the intrinsic function would cause the entire
program to crash. Now we catch the error and comment out the line that
had the issue.
  • Loading branch information
shadycuz committed Jul 9, 2023
1 parent 1a7982a commit 6fd7d06
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/cf2tf/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def convert_to_tf(self, manifest: Manifest):

return tf_resources

def resolve_values(
def resolve_values( # noqa: max-complexity=13
self,
data: Any,
allowed_func: functions.Dispatch,
Expand Down Expand Up @@ -181,7 +181,10 @@ def resolve_values(
value, functions.ALLOWED_FUNCTIONS[key], key, inside_function=True
)

return allowed_func[key](self, value)
try:
return allowed_func[key](self, value)
except Exception:
return CommentType(f"Unable to resolve {key} with value: {value}")

return MapType(data)
elif isinstance(data, list):
Expand Down

0 comments on commit 6fd7d06

Please sign in to comment.