8000 Add Format method to pythonexception by slide · Pull Request #1031 · pythonnet/pythonnet · GitHub
[go: up one dir, main page]

Skip to content

Add Format method to pythonexception #1031

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

Merged
merged 3 commits into from
Apr 8, 2020
Merged

Add Format method to pythonexception #1031

merged 3 commits into from
Apr 8, 2020

Conversation

slide
Copy link
Contributor
@slide slide commented Jan 15, 2020

What does this implement/fix? Explain your changes.

Adds a Format method to PythonException which calls traceback.format_exception to get a nice exception message similar to something you would see on the Python console.

Does this close any currently open issues?

No

Any other comments?

N/A

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

Allows formatting a PythonException using traceback.format_exception
}
catch (PythonException ex)
{
Assert.That(ex.Format(), Does.Contain("Traceback").And.Contains("(most recent call last):").And.Contains("ValueError: Error!"));
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if Python exceptions messages are localized. If that is the case, you need to ensure the right locale is used before performing this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will try and figure out if exception messages are localized.

@slide
Copy link
Contributor Author
slide commented Apr 8, 2020

Not sure why the Travis CI build is not showing up, it is here: https://travis-ci.org/github/pythonnet/pythonnet/builds/672296231

@lostmsu lostmsu merged commit 5d28a8d into pythonnet:master Apr 8, 2020
AlexCatarino pushed a commit to QuantConnect/pythonnet that referenced this pull request Jun 29, 2020
Allows formatting a PythonException using traceback.format_exception
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.

2 participants
0