Skip to content

Commit

Permalink
Oppdatere beregn forskudd api (#100)
Browse files Browse the repository at this point in the history
* BD-1764: Oppdatere grensensitt mot bidrag-beregn-forskudd-rest

* BD-1764: Endre datamodell. Beregne forskudd.

* Fikse bakoverkompatibilitet husstandsmedlemmer
  • Loading branch information
s148719 authored Dec 11, 2023
1 parent 9c72cf3 commit 9de0c57
Show file tree
Hide file tree
Showing 98 changed files with 2,696 additions and 1,549 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ target/
.mvn/wrapper/**
mvnw
mvnw.cmd
*.orig

### STS ###
.apt_generated
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<java.version>21</java.version>
<kotlin.version>1.9.21</kotlin.version>
<bidrag-commons.version>20231201131246_f719b2b</bidrag-commons.version>
<bidrag-transport.version>20231129081122_595a8a8</bidrag-transport.version>
<bidrag-transport.version>20231206085150_493c399</bidrag-transport.version>
<logback-encoder.version>7.4</logback-encoder.version>
<token-support.version>3.2.0</token-support.version>
<springdoc.version>2.3.0</springdoc.version>
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/no/nav/bidrag/behandling/Exceptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ fun fantIkkeFødselsdatoTilSøknadsbarn(behandlingsid: Long): Nothing =
HttpStatus.INTERNAL_SERVER_ERROR,
"Fant ikke fødselsdato til søknadsbarn i behandling med id $behandlingsid",
)

fun valideringAvBehandlingFeilet(valideringsfeil: List<String>): Nothing =
throw HttpClientErrorException(HttpStatus.BAD_REQUEST, valideringsfeil.toString())
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.nav.bidrag.behandling.controller
package no.nav.bidrag.behandling.aop

import com.fasterxml.jackson.databind.JsonMappingException
import com.fasterxml.jackson.databind.exc.InvalidFormatException
Expand Down Expand Up @@ -39,8 +39,7 @@ class ExceptionHandler {
validationError?.fieldErrors?.joinToString(", ") { "${it.field}: ${it.message}" }
?: "ukjent feil"

return ResponseEntity
.status(HttpStatus.BAD_REQUEST)
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.header(
HttpHeaders.WARNING,
"Forespørselen inneholder ugyldig verdi: $errorMessage",
Expand All @@ -52,15 +51,18 @@ class ExceptionHandler {
@ExceptionHandler(HttpStatusCodeException::class)
fun handleHttpClientErrorException(exception: HttpStatusCodeException): ResponseEntity<*> {
val errorMessage = getErrorMessage(exception)
return ResponseEntity
.status(exception.statusCode)
return ResponseEntity.status(exception.statusCode)
.header(HttpHeaders.WARNING, errorMessage)
.build<Any>()
}

private fun getErrorMessage(exception: HttpStatusCodeException): String {
val errorMessage = StringBuilder()
errorMessage.append("Det skjedde en feil ved kall mot ekstern tjeneste: ")
if (exception.statusText == null) {
errorMessage.append("Det skjedde en feil ved kall mot ekstern tjeneste: ")
} else {
errorMessage.append("Validering feilet")
}
exception.responseHeaders?.get(HttpHeaders.WARNING)?.firstOrNull()?.let { errorMessage.append(it) }
if (exception.statusText.isNotEmpty()) {
errorMessage.append(" - ")
Expand Down

This file was deleted.

Loading

0 comments on commit 9de0c57

Please sign in to comment.