question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide meaningful string representation for results.Error

See original GitHub issue

Is your feature request related to a problem? Please describe. When dealing with error, I feel that a str(error_instance) should give me some idea about the nature of the error, aka show Error.error.

Describe the solution you’d like Provide Error.__str__ that returns Error.error. One could think about including row information but I do not have a strong opinion on that one tbh.

Describe alternatives you’ve considered Obviously it is possible to be verbose and call error_instance.error. However, besides being verbose this requires the caller to know the attribute name where the actual error is stored.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
alexmndzdevcommented, Jan 31, 2019

I did this to show the errors, maybe is useful:

if result.has_errors():
    response = []
    index_row = 0
    for row in result.rows:
        index_row = index_row + 1
        for error in row.errors:
            messages = []
            for array_error in error.error:
                if (isinstance(array_error, str)):
                    messages.append(array_error)
                else:
                    messages.append(array_error[0].upper()+': '+array_error[1][0])
            response.append({'index': index_row, 'message' : messages})
response.append({'total': result.totals}) #This contains the result of records addeds and updateds
return HttpResponse(json.dumps(response), status = 400, content_type = 'application/json')
0reactions
stale[bot]commented, Jun 5, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I'm still confused on what toString() does (Example) - Treehouse
The main purpose of toString() method is to generate a String or text representation of a Java Class; in other words to provide...
Read more >
How to override the toString() method in Java - Educative.io
We want to get understandable information (string representation) of an object. We can override the toString() method in our class to print a...
Read more >
Object toString() Method in Java - GeeksforGeeks
Note: Default behavior of toString() is to print class name, then @, then unsigned hexadecimal representation of the hash code of the object....
Read more >
Custom toString() in java - Stack Overflow
toString (point) return the String representation of the point? Can anyone explain to me how to fix it? I'm sure it's a simple...
Read more >
Object.ToString Method (System) - Microsoft Learn
Returns a string that represents the current object.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found