-
Notifications
You must be signed in to change notification settings - Fork 2.2k
rpcperms: add gRPC codes to errors #5633
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
base: master
Are you sure you want to change the base?
rpcperms: add gRPC codes to errors #5633
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.
Love the thought that went into these!
I think that it would be useful to declare the error codes as their own vars so that they can be imported by go code that's using the interceptor.
Eg:
waitingToStartCode = 1001
ErrWaitingToStart = status.Error(waitingToStartCode, "waiting to start, RPC services not "+
"available")
Also would be great to add a comment re the system you used to create these above the error code vars so that we remember it! |
- new gRPC Codes have been added for better error matching retaining the old text for string matching - first digit indicates server related error - second digit indicates wallet related error - the third and fourth digit error number for the combination Signed-off-by: DarthBenro008 <[email protected]>
5a882b3
to
5cab026
Compare
Hey @carlaKC , I have implemented the required changes and added few comments! |
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.
LGTM! Just needs an entry in the 0.14 release notes as well.
@@ -5,6 +5,8 @@ import ( | |||
"fmt" | |||
"sync" | |||
|
|||
"google.golang.org/grpc/status" | |||
|
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.
nit: can remove newline here
var ( | ||
// ErrWaitingToStart is returned if LND is still wating to start, | ||
// possibly blocked until elected as the leader. | ||
ErrWaitingToStart = fmt.Errorf("waiting to start, RPC services not " + | ||
ErrWaitingToStart = status.Error(ErrWaitingToStartStatusCode, "waiting to start, RPC services not "+ |
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.
nit: wrap at 80
Thank you for the PR! I think the idea to use structured error codes is a great one! It means your PR would need some refactoring and the codes should probably be defined in the |
Hi @guggero , I actually thought of something really similar while working on this PR. I'm really glad that we can have it implemented over a broader scope. I think I can work on refactoring the changes (refactoring as well as adding the new error codes in the I'd suggest opening a new issue mentioning both the PR's and relevant issues with the proposed methodology, and then I can open a new PR against the new issue. That would make it easier to track everything related to error codes in the long term. If this is agreed upon, would be happy to open the issue 😃 |
Removing from the milestone for now. Can resurrect if the OP comes back. |
Eg:
01XX
would be something related to wallet, maybe its not unlocked or already unlocked10XX
would be something related to the server itself, like its not still yet to startup fullySigned-off-by: DarthBenro008 [email protected]
Pull Request Checklist