Closed cjdelisle closed 4 years ago
I can't speak for everyone, but I would say no. I'd prefer to not have highly invasive code changes to the codebase. Would also hurt readability for new developers. Since progress on this repo is generally slow, I'd prefer to prioritize more pressing issues.
Understood, thanks. I'll close this now and if anyone else has an opinion about it then they can re-open.
I wanted to ask before making the PR itself because making it will take a bit of time. Background:
error
doesn't have stack traces and it should.For the meat and potatos:
error
is replaced wither.R
https://github.com/pkt-cash/pktd/blob/master/btcutil/er/er.goerrors.Errorf()
becomeser.Errorf()
errors.New()
becomeser.New()
error
, thaterror
is wrapped usinger.E()
and it becomes ander.R
var Err er.ErrorType = er.NewErrorType("neutrino.Err")
ErrGetUtxoCancelled = Err.CodeWithDetail("ErrGetUtxoCancelled", "get utxo request cancelled")
er.R
is an instance of an error code:if ruleerror.ErrBadCheckpoint.Is(err) {
er.R
is an instance of any code in an error class:if !ruleerror.Err.Is(err) {
And now all errors
String()
to include the name and code (if applicable) and the stack trace.Is it slower? Certainly yes, by how much I didn't measure, but once this is implemented, any amount of it can be optimized or turned off by simply going into the
er.go
file.I want to know what people think before taking the idea any further.