Skip to content

Commit

Permalink
feat: improve open channel fail logging
Browse files Browse the repository at this point in the history
  • Loading branch information
sangaman committed Jun 10, 2020
1 parent 2df88c5 commit 4a74520
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/service/Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class Service {
});
} catch (e) {
const errorMessage = e.message || 'unknown';
throw errors.OPEN_CHANNEL_FAILURE(currency, nodeIdentifier, amount, errorMessage);
throw errors.OPEN_CHANNEL_FAILURE(currency, amount, errorMessage, nodeIdentifier);
}
}

Expand Down
15 changes: 11 additions & 4 deletions lib/service/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@ const errors = {
message: 'a pending call is ongoing that conflicts with this call',
code: errorCodes.PENDING_CALL_CONFLICT,
},
OPEN_CHANNEL_FAILURE: (currency: string, nodePubKey: string, amount: number, message: string) => ({
message: `failed to open channel with nodePubKey: ${nodePubKey}, currency: ${currency}, amount: ${amount}, message: ${message}`,
code: errorCodes.OPEN_CHANNEL_FAILURE,
}),
OPEN_CHANNEL_FAILURE: (currency: string, amount: number, errorMessage: string, nodeIdentifier?: string) => {
let message = `failed to open ${currency} channel for ${amount}`;
if (nodeIdentifier) {
message += ` with ${nodeIdentifier}`;
}
message += `: ${errorMessage}`;
return {
message,
code: errorCodes.OPEN_CHANNEL_FAILURE,
};
},
NODE_DOES_NOT_EXIST: {
message: 'xud node cannot be unlocked because it does not exist',
code: errorCodes.NODE_DOES_NOT_EXIST,
Expand Down

0 comments on commit 4a74520

Please sign in to comment.