Skip to content

Commit

Permalink
fix: wrap InvalidTemplateException's with InvalidDocumentException (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
torresxb1 authored May 3, 2022
1 parent 2be47df commit 8730d26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions samtranslator/plugins/sam_plugins.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from samtranslator.model.exceptions import InvalidResourceException, InvalidDocumentException
from samtranslator.model.exceptions import InvalidResourceException, InvalidDocumentException, InvalidTemplateException
from samtranslator.plugins import BasePlugin, LifeCycleEvents

LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -130,7 +130,7 @@ def act(self, event, *args, **kwargs):

try:
getattr(plugin, method_name)(*args, **kwargs)
except (InvalidResourceException, InvalidDocumentException) as ex:
except (InvalidResourceException, InvalidDocumentException, InvalidTemplateException) as ex:
# Don't need to log these because they don't result in crashes
raise ex
except Exception as ex:
Expand Down
5 changes: 3 additions & 2 deletions samtranslator/translator/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
InvalidResourceException,
DuplicateLogicalIdException,
InvalidEventException,
InvalidTemplateException,
)
from samtranslator.intrinsics.resolver import IntrinsicsResolver
from samtranslator.intrinsics.actions import FindInMapAction
Expand Down Expand Up @@ -163,7 +164,7 @@ def translate(self, sam_template, parameter_values, feature_toggle=None, passthr
document_errors.append(
DuplicateLogicalIdException(logical_id, resource.logical_id, resource.resource_type)
)
except (InvalidResourceException, InvalidEventException) as e:
except (InvalidResourceException, InvalidEventException, InvalidTemplateException) as e:
document_errors.append(e)

if deployment_preference_collection.any_enabled():
Expand All @@ -183,7 +184,7 @@ def translate(self, sam_template, parameter_values, feature_toggle=None, passthr
# Run the after-transform plugin target
try:
sam_plugins.act(LifeCycleEvents.after_transform_template, template)
except (InvalidDocumentException, InvalidResourceException) as e:
except (InvalidDocumentException, InvalidResourceException, InvalidTemplateException) as e:
document_errors.append(e)

# Cleanup
Expand Down

0 comments on commit 8730d26

Please sign in to comment.