Skip to content

Commit

Permalink
B - Retter bug der vi kaster en exception ved henting av info fra KRR
Browse files Browse the repository at this point in the history
Co-authored-by: Mariam Pervez <[email protected]>
  • Loading branch information
dskarpas and MariamPervez committed Nov 19, 2024
1 parent 266c756 commit 6a8e76b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
14 changes: 5 additions & 9 deletions src/main/kotlin/no/nav/eessi/pensjon/prefill/KrrService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class KrrService(private val krrRestTemplate: RestTemplate,
}

//Henter inn telefonnummer og epostadresse fra KRR for å preutfylle SED
fun hentPersonFraKrr(personIdent: String, inkluderSikkerDigitalPost: Boolean?= false): KrrPerson {
return HentPerson.measure {
fun hentPersonFraKrr(personIdent: String, inkluderSikkerDigitalPost: Boolean?= false): KrrPerson? {
HentPerson.measure {
val url = "/rest/v1/person?inkluderSikkerDigitalPost=$inkluderSikkerDigitalPost"
logger.debug("Henter informasjon fra KRR: $url")

Expand All @@ -45,15 +45,11 @@ class KrrService(private val krrRestTemplate: RestTemplate,

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

response.body?.let {
mapJsonToAny<KrrPerson>(it)
} ?: throw IllegalArgumentException("Mangler melding fra KRR")
return@measure response.body?.let { mapJsonToAny<KrrPerson>(it) } ?: throw IllegalArgumentException("Mangler melding fra KRR")
} catch (e: HttpClientErrorException.NotFound) {
throw IllegalArgumentException("Person: $personIdent ikke funnet (404)")
} catch (e: Exception) {
throw e
logger.error("Person: $personIdent ikke funnet (404)")
}
}

return null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class PrefillService(
private fun hentKrrPerson(norskIdent: String, request: ApiRequest): PersonInfo {
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
)
}

Expand All @@ -105,8 +105,7 @@ class PrefillService(
krrPerson.reservert,
krrPerson.epostadresse,
krrPerson.mobiltelefonnummer
)
.also { logger.info("Hentet telefon og epost fra KRR: ${krrPerson.toJson()}") }
).also { logger.info("Hentet telefon og epost fra KRR: ${krrPerson.toJson()}") }
}
return personInfo
}
Expand Down

0 comments on commit 6a8e76b

Please sign in to comment.