Skip to content

Commit

Permalink
Update InvalidSamDocumentException to a subclass of UserException
Browse files Browse the repository at this point in the history
  • Loading branch information
hawflau committed Jul 28, 2023
1 parent d841801 commit 7a36b03
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion samcli/commands/validate/lib/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
Custom Exceptions for 'sam validate' commands
"""

from samcli.commands.exceptions import UserException

class InvalidSamDocumentException(Exception):

class InvalidSamDocumentException(UserException):
"""
Exception for Invalid Sam Documents
"""
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def test_get_translate_dict_invalid_template_error(
}
},
}
mock_get_translated_template_if_valid.side_effect = InvalidSamDocumentException()
mock_get_translated_template_if_valid.side_effect = InvalidSamDocumentException("")
with self.assertRaises(InvalidSamTemplateException):
resource_producer = ResourceMappingProducer(
stack_name=None,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/commands/validate/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_template_fails_validation(self, patched_boto, read_sam_file_patch, clic
read_sam_file_patch.return_value = {"a": "b"}

get_translated_template_if_valid_mock = Mock()
get_translated_template_if_valid_mock.get_translated_template_if_valid.side_effect = InvalidSamDocumentException
get_translated_template_if_valid_mock.get_translated_template_if_valid.side_effect = InvalidSamDocumentException("")
template_valiadator.return_value = get_translated_template_if_valid_mock

with self.assertRaises(InvalidSamTemplateException):
Expand Down

0 comments on commit 7a36b03

Please sign in to comment.