routerrpc: map errors to grpc status code
The 'payment already exists' case is common in restart scenarios. With this commit it is no longer necessary to string-match on the error message. Implementation is identical to SendPaymentV2.
This commit is contained in:
parent
d26001a69a
commit
856abade3d
@ -375,6 +375,13 @@ func (s *Server) SendToRouteV2(ctx context.Context,
|
||||
return rpcAttempt, nil
|
||||
}
|
||||
|
||||
// Transform user errors to grpc code.
|
||||
if err == channeldb.ErrPaymentInFlight ||
|
||||
err == channeldb.ErrAlreadyPaid {
|
||||
|
||||
return nil, status.Error(codes.AlreadyExists, err.Error())
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user