Skip to content

Commit 6ccd224

Browse files
committed
Fixed error handling
1 parent 5899cce commit 6ccd224

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/infrastructure/Http.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,13 @@ export abstract class Http {
5959
}
6060

6161
errorHandling(error: any): Error {
62-
const formattedError = {
63-
statusCode: error.response.statusCode,
64-
errorDetails: error.response.body,
65-
};
66-
return new Error(JSON.stringify(formattedError));
62+
if (error.response && error.response.statusCode && error.response.body) {
63+
const formattedError = {
64+
statusCode: error.response.statusCode,
65+
errorDetails: error.response.body,
66+
};
67+
return new Error(JSON.stringify(formattedError));
68+
}
69+
return new Error(error);
6770
}
6871
}

test/infrastructure/TransactionHttp.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ describe('TransactionHttp', () => {
4949
return trnsHttp.announceAggregateBonded(signedTx)
5050
.toPromise()
5151
.then(() => {
52-
throw new Error('Should be called');
5352
})
5453
.catch((reason) => {
5554
expect(reason.toString()).to.be.equal('Only Transaction Type 0x4241 is allowed for announce aggregate bonded');

0 commit comments

Comments
 (0)