Skip to content

Commit d95bfc7

Browse files
committed
Fixed exception handling. Added e2e test around exception handling
Open api released version
1 parent dd2ad72 commit d95bfc7

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

e2e/infrastructure/AccountHttp.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,19 @@ describe('AccountHttp', () => {
225225
});
226226
});
227227

228+
describe('transactions', () => {
229+
it('should not return accounts when account does not exist', () => {
230+
return accountRepository.getAccountInfo(Account.generateNewAccount(networkType).address).toPromise().then(r => {
231+
return Promise.reject('should fail!');
232+
}, err => {
233+
const error = JSON.parse(err.message);
234+
expect(error.statusCode).to.be.eq(404);
235+
expect(error.errorDetails.statusMessage).to.be.eq('Not Found');
236+
return Promise.resolve();
237+
});
238+
});
239+
});
240+
228241
describe('transactions', () => {
229242
it('should call transactions successfully', (done) => {
230243
accountRepository.getAccountTransactions(publicAccount.address).subscribe((transactions) => {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"dependencies": {
6060
"bluebird": "^3.5.5",
6161
"catbuffer": "0.0.6-SNAPSHOT",
62-
"nem2-sdk-openapi-typescript-node-client": "0.7.2-0.6-SNAPSHOT.201912301439",
62+
"nem2-sdk-openapi-typescript-node-client": "0.7.2-0.6",
6363
"crypto-js": "^3.1.9-1",
6464
"js-joda": "^1.6.2",
6565
"js-sha256": "^0.9.0",

src/infrastructure/Http.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ export abstract class Http {
6161
if (error.response && error.response.statusCode && error.body) {
6262
const formattedError = {
6363
statusCode: error.response.statusCode,
64-
errorDetails: error.response,
64+
errorDetails: {
65+
statusCode: error.response.statusCode,
66+
statusMessage: error.response.statusMessage,
67+
},
6568
body: error.body,
6669
};
6770
return new Error(JSON.stringify(formattedError));

0 commit comments

Comments
 (0)