Skip to content

Handle exceptions by using traceback.format_exc instead of extract_tb#58

Merged
yxd-hde merged 3 commits into
HDE:masterfrom
danielthepope:handle-exceptions
Nov 25, 2019
Merged

Handle exceptions by using traceback.format_exc instead of extract_tb#58
yxd-hde merged 3 commits into
HDE:masterfrom
danielthepope:handle-exceptions

Conversation

@danielthepope

Copy link
Copy Markdown
Contributor

This fixes #57, where we were seeing TypeError: Object of type FrameSummary is not JSON serializable if the handler function throws an exception.

traceback.format_exc returns a string that can be easily turned into JSON.

@danielthepope

This comment has been minimized.

Comment thread lambda_local/main.py Outdated
result = json.dumps({
"errorMessage": str(err[1]),
"stackTrace": traceback.extract_tb(err[2]),
"stackTrace": traceback.format_exc(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using traceback.format_tb(err[2]) instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, that makes it look more like the error response provided by AWS now.

@yxd-hde yxd-hde left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR. Would you please check my comment? Thanks!

@yxd-hde yxd-hde merged commit 9b2433e into HDE:master Nov 25, 2019
@danielthepope danielthepope deleted the handle-exceptions branch November 25, 2019 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exceptions thrown in handler function make process hang

3 participants