@@ -16,6 +16,7 @@ import no.nav.medlemskap.common.exceptions.*
16
16
import v1.mt_1067_nav.no.udi.HentPersonstatusFault
17
17
18
18
private val logger = KotlinLogging .logger { }
19
+ private val secureLogger = KotlinLogging .logger(" tjenestekall" )
19
20
20
21
fun StatusPagesConfig.exceptionHandler () {
21
22
exception<GraphqlError > { call, cause ->
@@ -78,7 +79,7 @@ fun StatusPagesConfig.exceptionHandler() {
78
79
}
79
80
exception<GradertAdresseException > { call, cause ->
80
81
81
- call.logWarningAndRespond (cause, HttpStatusCode .ServiceUnavailable ) {
82
+ call.logSecureWarningAndRespond (cause, HttpStatusCode .ServiceUnavailable ) {
82
83
" GradertAdresse. Lovme skal ikke kalles for personer med kode 6/7"
83
84
}
84
85
}
@@ -149,6 +150,26 @@ private suspend inline fun ApplicationCall.logWarningAndRespond(
149
150
)
150
151
this .respond(status, response)
151
152
}
153
+ private suspend inline fun ApplicationCall.logSecureWarningAndRespond (
154
+ cause : Throwable ,
155
+ status : HttpStatusCode = HttpStatusCode .InternalServerError ,
156
+ lazyMessage : () -> String
157
+ ) {
158
+ val message = lazyMessage()
159
+ secureLogger.warn(
160
+ message,
161
+ kv(" cause" , cause),
162
+ kv(" callId" , callId)
163
+ )
164
+ val response = HttpErrorResponse (
165
+ url = this .request.uri,
166
+ cause = cause.toString(),
167
+ message = message,
168
+ code = status,
169
+ callId = getCorrelationId(callId)
170
+ )
171
+ this .respond(status, response)
172
+ }
152
173
153
174
internal data class HttpErrorResponse (
154
175
val url : String ,
0 commit comments