Skip to content

Commit

Permalink
Improve log of axios error
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagogoncalves89 committed Oct 20, 2020
1 parent 6789877 commit c413f23
Show file tree
Hide file tree
Showing 3 changed files with 2,471 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/logger-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class LoggerFilter {
}

if (item instanceof Error) {
return serializeError(item);
return this.filterError(item);
}

if (this.isPlainObject(item)) {
Expand Down Expand Up @@ -108,4 +108,22 @@ export class LoggerFilter {
);
return newBlackList.concat(includeBlackList);
}

private filterError(error: any) {
if (error.isAxiosError) {
return serializeError({
config: error.config,
message: error.message,
name: error.name,
response: {
status: error.response.status,
statusText: error.response.statusText,
headers: error.response.headers,
data: error.response.data,
},
});
}

return serializeError(error);
}
}
Loading

0 comments on commit c413f23

Please sign in to comment.