Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve http requests logging #150

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/routes/webhook/webhook.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,23 @@ export class WebhookService {
return firstValueFrom(
this.httpService.post(url, parsedMessage, { headers }).pipe(
catchError((error: AxiosError) => {
this.logger.error(`Error sending event to ${url}`, error);
const strMessage = JSON.stringify(parsedMessage);
if (error.response !== undefined) {
// Response received status code but status code not 2xx
this.logger.error(
`Error sending event ${strMessage} to ${url}: ${error.response.status} ${error.response.statusText} - ${error.response.data}`,
);
} else if (error.request !== undefined) {
// Request was made but response was not received
this.logger.error(
`Error sending event ${strMessage} to ${url}: Response not received`,
);
} else {
// Cannot make request
this.logger.error(
`Error sending event ${strMessage} to ${url}: ${error.message}`,
);
}
return of(undefined);
}),
),
Expand Down