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

Logging multi-line errors isn't multi-line #87

Open
Lucretiel opened this issue Dec 2, 2016 · 0 comments
Open

Logging multi-line errors isn't multi-line #87

Lucretiel opened this issue Dec 2, 2016 · 0 comments

Comments

@Lucretiel
Copy link

I have a function that returns an error that includes a stack trace:

result, err := my_func()
c.Assert(err, IsNil)
# err may have a long, multi-line message

When I test for nil on the error, the error message is long and not super helpful:

.../.../my_test.go:
    c.Assert(err, isNil)
... value *errors.baseError = &errors.baseError{msg:"long msg", <other error fields>} ("long msg")

In this case, the "long msg" is duplicated, and the message itself is printed in "repr" form, meaning that newlines (and other control characters) show up as "\n" and the message is basically completely unreadable.

The problem appears to be rooted here. The problem is that the "go syntax" repr and the "quoted" repr aren't equal, so it's written twice, and what's written isn't written in a useful way. I understand that, in general, you want to have this kind of representation for arbitrary interface{} values, but for error I think there should be some kind of new representation which makes use of isMultiLine, and at the very least doesn't duplicate all the internal baseError data or write the error message twice. I was working on a P/R but I wasn't sure what that new representation should be.

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

1 participant