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

ErrorResult could use a top-level 'code' attribute to match the 'message' attribute #6

Closed
foresto opened this issue Aug 13, 2010 · 3 comments

Comments

@foresto
Copy link

foresto commented Aug 13, 2010

The ErrorResult class has a top-level message attribute which is a convenient alternative to groveling through the children of errors when only the first/main error message is needed for display. Unfortunately, there is no matching code attribute, so there's no good way to take programmatic action based on what kind of error it is.

As far as I can tell, there is also no documentation indicating which child of errors was used for the top-level message, so grabbing an error code from there would seem unreliable at best.

@braintreeps
Copy link
Contributor

Result objects have a deep_errors attribute that returns a flattened list of all errors at all levels. You can simply grab the code of the first error, or grab all of the codes, and take programmatic action based on the codes you see.

Take a look at http://www.braintreepaymentsolutions.com/docs/python/general/validation_errors#all_errors_on_all_levels

Please let us know if deep_errors does not accomplish what you are looking for.

@foresto
Copy link
Author

foresto commented Aug 13, 2010

Right, I'm aware of deep_errors and can get by with it. This issue is really more of a feature request than a bug. The top-level message would be more generally useful if it had a matching code attribute, to bring it into parity with all the other error objects in an ErrorResult. Failing that, it would be nice at least to have documentation indicating which of the errors in deep_errors is represented by the top level message.

@braintreeps
Copy link
Contributor

The top level message is a string containing all of the error messages (validation errors, processor declined, etc). Since there can be more than one error, there is no one code that matches. We will update the docs to make this more clear.

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

No branches or pull requests

3 participants