Skip to content

Commit

Permalink
Log propertly response data objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Uxio0 committed Feb 27, 2024
1 parent be2774a commit 55f4a94
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/routes/webhook/webhook.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,14 @@ export class WebhookService {
const strMessage = JSON.stringify(parsedMessage);
if (error.response !== undefined) {
// Response received status code but status code not 2xx
let dataStr: string;
try {
dataStr = JSON.stringify(error.response.data);
} catch (_) {
dataStr = 'Cannot parse response data';
}
this.logger.error(
`Error sending event ${strMessage} to ${url}: ${error.response.status} ${error.response.statusText} - ${error.response.data}`,
`Error sending event ${strMessage} to ${url}: ${error.response.status} ${error.response.statusText} - ${dataStr}`,
);
} else if (error.request !== undefined) {
// Request was made but response was not received
Expand Down

0 comments on commit 55f4a94

Please sign in to comment.