From 626983b352cae1d40a09c990194f5c912b621371 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 14 Jan 2021 13:59:56 +0100 Subject: [PATCH] rpcserver: use NotFound http status code in GetNodeInfo --- rpcserver.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rpcserver.go b/rpcserver.go index 1d0c707c..c827d8a5 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -73,6 +73,8 @@ import ( "github.com/lightningnetwork/lnd/zpay32" "github.com/tv42/zbase32" "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "gopkg.in/macaroon-bakery.v2/bakery" ) @@ -5219,7 +5221,10 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context, // to this public key. If the node cannot be found, then an error will // be returned. node, err := graph.FetchLightningNode(nil, pubKey) - if err != nil { + switch { + case err == channeldb.ErrGraphNodeNotFound: + return nil, status.Error(codes.NotFound, err.Error()) + case err != nil: return nil, err }