mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-18 21:35:24 +01:00
routerrpc: make sure error is transformed into grpc error code
This commit is contained in:
parent
17a0a8de06
commit
36f9d7b8db
@ -324,6 +324,19 @@ func (s *Server) SendPaymentV2(req *SendPaymentRequest,
|
||||
// Init the payment in db.
|
||||
paySession, shardTracker, err := s.cfg.Router.PreparePayment(payment)
|
||||
if err != nil {
|
||||
log.Errorf("SendPayment async error for payment %x: %v",
|
||||
payment.Identifier(), err)
|
||||
|
||||
// Transform user errors to grpc code.
|
||||
if errors.Is(err, channeldb.ErrPaymentExists) ||
|
||||
errors.Is(err, channeldb.ErrPaymentInFlight) ||
|
||||
errors.Is(err, channeldb.ErrAlreadyPaid) {
|
||||
|
||||
return status.Error(
|
||||
codes.AlreadyExists, err.Error(),
|
||||
)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user