Skip to content

Commit 3f57ca8

Browse files
committed
Resend utbetaling: Wrap hver resending i en try-catch
1 parent c373f70 commit 3f57ca8

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

økonomi/application/src/main/kotlin/økonomi/application/utbetaling/ResendUtbetalingService.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package økonomi.application.utbetaling
22

33
import arrow.core.Either
4+
import arrow.core.flatten
45
import arrow.core.getOrElse
56
import arrow.core.left
67
import arrow.core.right
@@ -51,7 +52,17 @@ class ResendUtbetalingService(
5152
utbetalingsIder: List<UUID30>,
5253
): List<Either<KunneIkkeSendeUtbetalingPåNytt, Utbetaling.OversendtUtbetaling>> {
5354
return utbetalingsIder.map { utbetalingId ->
54-
resendUtbetaling(utbetalingId)
55+
Either.catch {
56+
log.info("Resend utbetaling: Resender utbetalingId $utbetalingId")
57+
resendUtbetaling(utbetalingId)
58+
}.mapLeft {
59+
log.error(
60+
"Resend utbetaling: Ukjent feil. Kunne ikke resende utbetalingId $utbetalingId",
61+
RuntimeException("Trigger stacktrace for enklere debugging"),
62+
)
63+
sikkerLogg.error("Resend utbetaling: Ukjent feil. Kunne ikke resende utbetalingId $utbetalingId", it)
64+
KunneIkkeSendeUtbetalingPåNytt.UkjentFeil(utbetalingId)
65+
}.flatten()
5566
}.also {
5667
log.info("Resend utbetaling: ${it.count { it.isRight() }} av ${utbetalingsIder.size} utbetalinger ble sendt på nytt. $it")
5768
}
@@ -262,4 +273,8 @@ sealed interface KunneIkkeSendeUtbetalingPåNytt {
262273
val sakId: UUID,
263274
val vedtakId: UUID,
264275
) : KunneIkkeSendeUtbetalingPåNytt
276+
277+
data class UkjentFeil(
278+
override val utbetalingId: UUID30,
279+
) : KunneIkkeSendeUtbetalingPåNytt
265280
}

0 commit comments

Comments
 (0)