Skip to content

Commit

Permalink
Peer Gateway txs error messsage: added output of the contents of the …
Browse files Browse the repository at this point in the history
…err details array (#1345)

Signed-off-by: fraVlaca <ocsenarf@outlook.com>
  • Loading branch information
fraVlaca committed May 17, 2022
1 parent 671ca2f commit df1b96c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,13 @@ class PeerGateway extends ConnectorBase {
return invokeStatus;
} catch (err) {
//check if transaction submission failed, set invokation status accordingly and return it
logger.error(`Failed to perform ${isSubmit ? 'submit' : 'query'} transaction [${invokeSettings.contractFunction}] using arguments [${invokeSettings.contractArguments}], with error: ${err.stack ? err.stack : err}`);
if (err.details) {
err.message += '\nDetails:';
for (const detail of err.details) {
err.message += `\n- ${detail.address}:${detail.message}`;
}
}
logger.error(`Failed to perform ${isSubmit ? 'submit' : 'query'} transaction [${invokeSettings.contractFunction}] using arguments [${invokeSettings.contractArguments}], with error: ${err}`);
invokeStatus.SetStatusFail();
invokeStatus.SetVerification(true);
invokeStatus.SetResult('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,9 @@ describe('A Fabric Peer Gateway sdk gateway', () => {
contractArguments: args,
invokerIdentity: 'admin',
};
Transaction.throwOnCall(new Error('submit-failure'));
const err = new Error('submit-failure');
err.details= [{address:'anaddress', message:'an error'},{},'something'];
Transaction.throwOnCall(err);
const txStatus = await peerGateway._sendSingleRequest(request);
txStatus.should.be.instanceOf(TxStatus);
txStatus.GetStatus().should.equal('failed');
Expand Down Expand Up @@ -503,7 +505,8 @@ describe('A Fabric Peer Gateway sdk gateway', () => {
invokerIdentity: 'admin',
readOnly: true
};
Transaction.throwOnCall(new Error('submit-failure'));
const err = new Error('submit-failure');
Transaction.throwOnCall(err);
const txStatus = await peerGateway._sendSingleRequest(request);
txStatus.should.be.instanceOf(TxStatus);
txStatus.GetStatus().should.equal('failed');
Expand Down

0 comments on commit df1b96c

Please sign in to comment.