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

fix: wrap InvalidTemplateException's with InvalidDocumentException #2391

Merged
merged 1 commit into from
May 3, 2022
Merged
Show file tree
Hide file tree
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
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