Skip to content

Conversation

@carlaKC
Copy link
Contributor

@carlaKC carlaKC commented Jul 19, 2021

Formatting our error was stifling any grpc error returned by the
server. Instead, we bubble up our grpc error, setting an unknown
code if the server did not specifically return an error code.

Fixes: #355

Pull Request Checklist

  • Update release_notes.md if your PR contains major features, breaking changes or bugfixes

carlaKC added 2 commits July 19, 2021 10:28
Formatting our error was stifling any grpc error returned by the
server. Instead, we bubble up our grpc error, setting an unknown
code if the server did not specifically return an error code.
@carlaKC carlaKC requested review from bhandras and guggero July 19, 2021 08:38
Copy link
Contributor

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK, LGTM 💯

Before:

[loop] rpc error: code = Unknown desc = cannot initiate swap: rpc error: code = FailedPrecondition desc = target unreachable

After:

[loop] rpc error: code = FailedPrecondition desc = cannot initiate swap: target unreachable

Copy link
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

// wrapGrpcError wraps the non-nil error provided with a message providing
// additional context, preserving the grpc code returned with the original
// error. If the original error has no grpc code, then codes.Unknown is used.
func wrapGrpcError(message string, err error) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an advantage of wrapping unknown errors in the few places in the PR vs just returning status.Error there with proper error codes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's nice to be able to wrap with a bit more information and preserve the error? In the case of unknown errors, I think it's ok to add the unknown error code anyway, doesn't really take away much. We could go through the whole api and add error codes everywhere, but I think surfacing the error codes returned by the server is a good start?

@carlaKC carlaKC merged commit 478f242 into lightninglabs:master Jul 21, 2021
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

Successfully merging this pull request may close these issues.

Loop In: real server error is swallowed

3 participants