Skip to content

Commit

Permalink
Mm/prc 0 log non axios errors (#54)
Browse files Browse the repository at this point in the history
Release 5.2.2
  • Loading branch information
mmaruniak authored Aug 25, 2023
1 parent dc8abc5 commit fbc8440
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)

## [5.2.2] - 2023-08-25

### Added

HttpClient now also logs unexpected (e.g. network) errors that are not coming from Axios

## [5.2.0] - 2023-06-08

### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lambda-essentials-ts",
"version": "5.2.1",
"version": "5.2.2",
"description": "A selection of the finest modules supporting authorization, API routing, error handling, logging and sending HTTP requests.",
"main": "lib/index.js",
"private": false,
Expand Down
5 changes: 4 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ export function serializeObject(obj: unknown, redact?: boolean): object {

export function serializeAxiosError(error: AxiosError): SerializedAxiosError | undefined {
if (!error.response) {
return undefined;
return {
status: 500,
details: error,
};
}

const { status, data } = error.response;
Expand Down
10 changes: 10 additions & 0 deletions tests/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ describe('Util', () => {
name: 'test-name',
toJSON: () => ({}),
};

test('serializes AxiosError objects', () => {
const expected = {
details: 'test-details',
Expand All @@ -105,6 +106,15 @@ describe('Util', () => {
const serializedError = serializeAxiosError(axiosError);
expect(serializedError).toEqual(expected);
});

test('serializes any objects', () => {
const expected = {
details: error,
status: 500,
};
const serializedError = serializeAxiosError(error as any);
expect(serializedError).toEqual(expected);
});
});

describe('redactSecret', () => {
Expand Down

0 comments on commit fbc8440

Please sign in to comment.