Content-Length: 286242 | pFad | https://github.com/HDE/python-lambda-local/pull/58#event-2826718998

C5 Handle exceptions by using traceback.format_exc instead of extract_tb by danielthepope · Pull Request #58 · HDE/python-lambda-local · GitHub
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

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

Merged
merged 3 commits into from
Nov 25, 2019

Conversation

danielthepope
Copy link
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.

@@ -124,7 +124,7 @@ def execute(func, event, context):
err = sys.exc_info()
result = json.dumps({
"errorMessage": str(err[1]),
"stackTrace": traceback.extract_tb(err[2]),
"stackTrace": traceback.format_exc(),
Copy link
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
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.

Copy link
Contributor

@yxd-hde yxd-hde left a comment

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
2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/HDE/python-lambda-local/pull/58#event-2826718998

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy