-
Notifications
You must be signed in to change notification settings - Fork 268
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
Add common error prefix #291
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost. Can you clean it up and then we merge?
@@ -391,3 +392,13 @@ func TestSetNamespace(t *testing.T) { | |||
}) | |||
} | |||
} | |||
|
|||
func compareErrors(err1, err2 error) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think reflect.DeepEqual
does exactly what compareErrors
does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The underlying stack trace captures will be different:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn. That's not nice since the error itself doesn't change. It doesn't really matter where it occurs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a comment to this function referring to your play.golang.org link. My guess is that this will bite us at some point when users expect reflect.DeepEqual
to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just got bitten by this in two ways. First, that errors
now adds a prefix and then that the comparison did not work. I'll expose the compare function so that we can use that in tests but it would be nice if we could find a more generic solution.
@@ -3,7 +3,7 @@ package uapolicy | |||
import ( | |||
"crypto" | |||
"crypto/hmac" | |||
"errors" | |||
"github.com/gopcua/opcua/errors" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sort pkg name
"sort" | ||
|
||
"github.com/gopcua/opcua/errors" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop blank line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you using a different fmt tool? go fmt
doesn't report any issues this or uapolicy/crypto_hmac.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I'm just a stickler for these things. I believe in consistency and that developers don't read code but pattern match it. So any deviation from the structure slows you down b/c you fall back to the slower "read code" mode.
@@ -124,7 +124,7 @@ func (s *SecureChannel) SendRequest(req ua.Request, authToken *ua.NodeID, h func | |||
func (s *SecureChannel) SendRequestWithTimeout(req ua.Request, authToken *ua.NodeID, timeout time.Duration, h func(interface{}) error) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this belongs to a different patch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea how this is contaminating my branch. I even redid this PR from scratch.
See #291 (comment) for discussion
Fixes #253