diff --git a/src/ntfy/client.ts b/src/ntfy/client.ts index 14e87b2..b8971b4 100644 --- a/src/ntfy/client.ts +++ b/src/ntfy/client.ts @@ -2,6 +2,7 @@ import { Inject, Injectable } from '@nestjs/common' import { ConfigService } from '@nestjs/config' import { Axios } from 'axios' +import { LoggerService } from '../logger/service.logger' import { MessageConfig } from './types' @Injectable() @@ -11,6 +12,9 @@ export class NtfyClient { constructor( @Inject(ConfigService) private readonly configService: ConfigService, + + @Inject(LoggerService) + private readonly loggerService: LoggerService, ) { const host = this.configService.getOrThrow('NTFY_HOST') this.topic = this.configService.getOrThrow('NTFY_TOPIC') @@ -25,12 +29,16 @@ export class NtfyClient { } async publish(message: Omit) { - return await this.httpClient.post( - '/', - JSON.stringify({ - topic: this.topic, - ...message, - }), - ) + try { + await this.httpClient.post( + '/', + JSON.stringify({ + topic: this.topic, + ...message, + }), + ) + } catch (error: unknown) { + this.loggerService.error('ntfy client failed', { error }) + } } } diff --git a/src/reservations/worker.ts b/src/reservations/worker.ts index 54bc148..63039b8 100644 --- a/src/reservations/worker.ts +++ b/src/reservations/worker.ts @@ -65,7 +65,7 @@ export class ReservationsWorker { } default: this.loggerService.error('Error while performing reservation', error) - this.ntfyProvider.sendErrorPerformingReservationNotification( + await this.ntfyProvider.sendErrorPerformingReservationNotification( reservation.id, reservation.dateRangeStart, reservation.dateRangeEnd,