Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Better error messages for method argument mismatch and others #1361

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 5 commits into from
Jan 27, 2021

Conversation

tminka
Copy link
Contributor

@tminka tminka commented Jan 21, 2021

What does this implement/fix? Explain your changes.

This change produces more specific error messages by passing setError=true to Converter.ToManaged whenever possible, such as when there is only one method in methodbinder. To support this:

  • Converter.ToManaged is fixed to obey setError consistently
  • Converter.ToArray catches exceptions
  • RaiseTypeError appends any existing error message
  • Fixed missing information on 'No method matches given arguments' by adding the method name.

Does this close any currently open issues?

No, but it provides more information to the user when they come across issues like #1099 . Instead of "No method matches" or "No match found" it now says TypeError : 'int' value cannot be converted to System.Enum

Any other comments?

I added some failing test cases to test_array.py that should be addressed by a future PR.

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

… value conversion, and other problems

Converter.ToManaged obeys setError consistently
PyObject_Hash and tp_hash return nint
MakeGenericType and MakeGenericMethod have try/catch
RaiseTypeError sets __cause__ instead of changing the message string
AggregateExceptions print better from Python
For an overloaded method, MethodBinder.Bind collects all binding errors
@lostmsu lostmsu merged commit 92932fd into pythonnet:master Jan 27, 2021
@tminka tminka deleted the error-messages branch January 27, 2021 22:05
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