Skip to content

Commit

Permalink
Resend utbetaling: Wrap hver resending i en try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
hestad committed Jan 5, 2024
1 parent c373f70 commit 3f57ca8
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package økonomi.application.utbetaling

import arrow.core.Either
import arrow.core.flatten
import arrow.core.getOrElse
import arrow.core.left
import arrow.core.right
Expand Down Expand Up @@ -51,7 +52,17 @@ class ResendUtbetalingService(
utbetalingsIder: List<UUID30>,
): List<Either<KunneIkkeSendeUtbetalingPåNytt, Utbetaling.OversendtUtbetaling>> {
return utbetalingsIder.map { utbetalingId ->
resendUtbetaling(utbetalingId)
Either.catch {
log.info("Resend utbetaling: Resender utbetalingId $utbetalingId")
resendUtbetaling(utbetalingId)
}.mapLeft {
log.error(
"Resend utbetaling: Ukjent feil. Kunne ikke resende utbetalingId $utbetalingId",
RuntimeException("Trigger stacktrace for enklere debugging"),
)
sikkerLogg.error("Resend utbetaling: Ukjent feil. Kunne ikke resende utbetalingId $utbetalingId", it)
KunneIkkeSendeUtbetalingPåNytt.UkjentFeil(utbetalingId)
}.flatten()
}.also {
log.info("Resend utbetaling: ${it.count { it.isRight() }} av ${utbetalingsIder.size} utbetalinger ble sendt på nytt. $it")
}
Expand Down Expand Up @@ -262,4 +273,8 @@ sealed interface KunneIkkeSendeUtbetalingPåNytt {
val sakId: UUID,
val vedtakId: UUID,
) : KunneIkkeSendeUtbetalingPåNytt

data class UkjentFeil(
override val utbetalingId: UUID30,
) : KunneIkkeSendeUtbetalingPåNytt
}

0 comments on commit 3f57ca8

Please sign in to comment.