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

Commit

Permalink
fix: client error wrapper display the first error
Browse files Browse the repository at this point in the history
Signed-off-by: Diego Barahona <[email protected]>
  • Loading branch information
diestrin committed May 9, 2019
1 parent 4b380af commit b80312a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions @worldsibu/convector-core-errors/src/client.errors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/** @module @worldsibu/convector-core-errors */

import { BaseError } from './base.error';
import { chaincodeSideMessage } from './common';

export interface ClientChaincodeResponse {
error?: any;
Expand All @@ -15,6 +14,12 @@ export class ClientResponseError extends BaseError {

constructor(public responses: ClientChaincodeResponse[]) {
super();
this.message = super.getMessage(super.getOriginal());
const firstResWithErr = responses.find(res => res.error);
this.message = super.getMessage(firstResWithErr ?
firstResWithErr.error instanceof Error ?
firstResWithErr.error.stack :
JSON.stringify(firstResWithErr.error) :
this.getOriginal()
);
}
}

0 comments on commit b80312a

Please sign in to comment.