Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

Commit

Permalink
feat: attach rejection to error
Browse files Browse the repository at this point in the history
  • Loading branch information
sentientwaffle committed Mar 17, 2020
1 parent 9a702f4 commit 476c12d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,10 @@ export class Connection extends EventEmitter {
await new Promise((resolve, reject) => setTimeout(resolve, delay))
} else {
this.log.error('unexpected error. code: %s, triggered by: %s, message: %s, data: %h', reject.code, reject.triggeredBy, reject.message, reject.data)
throw new Error(`Unexpected error while sending packet. Code: ${reject.code}, triggered by: ${reject.triggeredBy}, message: ${reject.message}`)
// This error will terminate the connection and bubble out to the caller.
const error = new Error(`Unexpected error while sending packet. Code: ${reject.code}, triggered by: ${reject.triggeredBy}, message: ${reject.message}`)
error['ilpReject'] = reject
throw error
}
}

Expand Down
1 change: 1 addition & 0 deletions test/connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,7 @@ describe('Connection', function () {
assert.equal(spy1.args[0][0].message, 'Total received exceeded MaxUint64')
assert.calledOnce(spy2)
assert.equal(spy2.args[0][0].message, 'Unexpected error while sending packet. Code: F00, triggered by: test.peerA, message: Total received exceeded MaxUint64')
assert.equal(spy2.args[0][0].ilpReject.code, 'F00')
})

it('supports a fixed maximumPacketAmount', async function () {
Expand Down

0 comments on commit 476c12d

Please sign in to comment.