forked from aws/aws-sam-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handled unhandled exception to show bug report message (aws#4565)
* Handled unhandled exception to show bug report message * Fix linting issues * run black reformat * Update message text and add unit test * Run black reformat * add test cases * Update actual exitcode of UnhandledException to 1 to not break existing behavior * remove unused import * address feedback * Update messaging * Update Unit Tests GH Action to make sure Bug_report.md exists * Update bug report * Update Bug Report template * fix typo * Update wording * update test
- Loading branch information
Showing
6 changed files
with
118 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import io | ||
|
||
from unittest import TestCase | ||
from unittest.mock import patch, Mock | ||
|
||
|
||
from samcli.commands.exceptions import UnhandledException | ||
|
||
|
||
class TestUnhandledException(TestCase): | ||
def test_show_must_print_traceback_and_message(self): | ||
wrapped_exception = None | ||
try: | ||
raise Exception("my_exception") | ||
except Exception as e: | ||
wrapped_exception = e | ||
|
||
unhandled_exception = UnhandledException("test_command", wrapped_exception) | ||
f = io.StringIO() | ||
unhandled_exception.show(f) | ||
|
||
output = f.getvalue() | ||
|
||
self.assertIn("Traceback:", output) | ||
self.assertIn('raise Exception("my_exception")', output) | ||
self.assertIn( | ||
'An unexpected error was encountered while executing "test_command".\n' | ||
"Search for an existing issue:\n" | ||
"https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20test_command%20-%20Exception\n" | ||
"Or create a bug report:\n" | ||
"https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20test_command%20-%20Exception", | ||
output, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters