Skip to content

Commit

Permalink
F - Legger inn håndtering av andre exceptions enn HttpClientErrorExce…
Browse files Browse the repository at this point in the history
…ption not found
  • Loading branch information
dskarpas committed Jan 6, 2025
1 parent a9b0536 commit 06ada72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/main/kotlin/no/nav/eessi/pensjon/prefill/KrrService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ class KrrService(private val krrRestTemplate: RestTemplate,
)

logger.debug("Hent person fra KRR: response: ${response.body}".trimMargin())

return@measure response.body?.let { mapJsonToAny<KrrPerson>(it) }
?: throw IllegalArgumentException("Mangler melding fra KRR")
} catch (e: HttpClientErrorException.NotFound) {
logger.error("Person: $personIdent ikke funnet (404)")
}
catch (e: Exception) {
logger.error("Feil ved henting av person fra KRR, ${e.message}")
}
null
}
}
Expand Down
16 changes: 10 additions & 6 deletions src/main/kotlin/no/nav/eessi/pensjon/prefill/PrefillService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,17 @@ class PrefillService(
}

private fun hentKrrPerson(norskIdent: String, request: ApiRequest): PersonInfo {
val krrPerson = krrService.hentPersonFraKrr(norskIdent).let { personResponse ->
val krrPerson = krrService.hentPersonFraKrr(norskIdent)?.let { personResponse ->
KrrPerson(
reservert = personResponse?.reservert,
epostadresse = personResponse?.epostadresse.validateEmail(request.processDefinitionVersion),
mobiltelefonnummer = personResponse?.mobiltelefonnummer
)
}
reservert = personResponse.reservert,
epostadresse = personResponse.epostadresse.validateEmail(request.processDefinitionVersion),
mobiltelefonnummer = personResponse.mobiltelefonnummer
).also { logger.debug("KrrPerson: ${it.toJson()}") }
} ?: KrrPerson(
reservert = false,
epostadresse = null,
mobiltelefonnummer = null
)

val personInfo = if (krrPerson.reservert == true) {
PersonInfo(
Expand Down

0 comments on commit 06ada72

Please sign in to comment.