Skip to content

Commit

Permalink
http: update to use new error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
josephjclark committed Jan 11, 2024
1 parent 623aa4c commit 72f67f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 7 additions & 1 deletion packages/http/src/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ export function request(method, path, params, callback = s => s) {
response,
};
})
.then(callback);
.then(callback)
.catch(err => {
const log = generateResponseLog(err);
console.log(log);

throw err;
});
};
}
7 changes: 4 additions & 3 deletions packages/http/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ describe('get()', () => {
body: { x: 31 },
statusCode: 201,
statusMessage: 'Created',
url: 'https://www.example.com/json',
});
assert.isNumber(duration);
assert.isAtLeast(duration, 0);
Expand Down Expand Up @@ -316,15 +317,15 @@ describe('get()', () => {
error = e;
}

const { code, url, method, duration, name } = error;
const { statusCode, url, method, duration, name } = error;
expect({
code,
statusCode,
url,
method,
name,
}).to.eql({
name: 'Error',
code: 404,
statusCode: 404,
url: 'https://www.example.com/api/404',
method: 'GET',
});
Expand Down

0 comments on commit 72f67f0

Please sign in to comment.