Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix(grpc): use grpc error details if available
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed May 10, 2020
1 parent 64a006a commit c278f3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions services/grpc/lightning.methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ async function openChannel(payload = {}) {
resolve(response)
})

call.on('error', data => {
grpcLog.error('OPEN_CHANNEL ERROR', data)
const error = new Error(data.message)
error.payload = parsePayload(payload)
reject(error)
call.on('error', error => {
grpcLog.error('OPEN_CHANNEL ERROR', error)
const e = new Error(error.details || error.message)
e.payload = parsePayload(payload)
reject(e)
})

call.on('status', status => {
Expand Down Expand Up @@ -234,11 +234,11 @@ async function closeChannel(payload = {}) {
resolve(response)
})

call.on('error', data => {
grpcLog.error('CLOSE_CHANNEL ERROR', data)
const error = new Error(data.message)
error.payload = { chanId }
reject(error)
call.on('error', error => {
grpcLog.error('CLOSE_CHANNEL ERROR', error)
const e = new Error(error.details || error.message)
e.payload = { chanId }
reject(e)
})

call.on('status', status => {
Expand Down
4 changes: 2 additions & 2 deletions services/grpc/router.methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async function probePayment(options) {

call.on('error', e => {
grpcLog.warn('PROBE ERROR :%o', e)
error = e
error = new Error(e.details || e.message)
})

call.on('end', () => {
Expand Down Expand Up @@ -162,7 +162,7 @@ async function sendPayment(options = {}) {

call.on('error', e => {
grpcLog.warn('PAYMENT ERROR :%o', e)
error = e
error = new Error(e.details || e.message)
})

call.on('end', () => {
Expand Down

0 comments on commit c278f3a

Please sign in to comment.