1
1
package no.nav.klage.document.config
2
2
3
3
import no.nav.klage.document.exceptions.MissingAccessException
4
- import no.nav.klage.document.util.getSecureLogger
4
+ import no.nav.klage.document.util.getLogger
5
5
import org.springframework.http.HttpStatus
6
6
import org.springframework.http.ProblemDetail
7
7
import org.springframework.orm.jpa.JpaObjectRetrievalFailureException
@@ -14,20 +14,19 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExcep
14
14
class ProblemHandlingControllerAdvice : ResponseEntityExceptionHandler () {
15
15
16
16
companion object {
17
- private val secureLogger = getSecureLogger()
17
+ @Suppress(" JAVA_CLASS_ON_COMPANION" )
18
+ private val ourLogger = getLogger(javaClass.enclosingClass)
18
19
}
19
20
20
21
@ExceptionHandler
21
22
fun handleEntityNotFound (
22
23
ex : JpaObjectRetrievalFailureException ,
23
- request : NativeWebRequest
24
24
): ProblemDetail =
25
25
create(HttpStatus .NOT_FOUND , ex)
26
26
27
27
@ExceptionHandler
28
28
fun handleMissingAccess (
29
29
ex : MissingAccessException ,
30
- request : NativeWebRequest
31
30
): ProblemDetail =
32
31
create(HttpStatus .FORBIDDEN , ex)
33
32
@@ -48,11 +47,11 @@ class ProblemHandlingControllerAdvice : ResponseEntityExceptionHandler() {
48
47
private fun logError (httpStatus : HttpStatus , errorMessage : String , exception : Exception ) {
49
48
when {
50
49
httpStatus.is5xxServerError -> {
51
- secureLogger .error(" Exception thrown to client: ${httpStatus.reasonPhrase} , $errorMessage " , exception)
50
+ ourLogger .error(" Exception thrown to client: ${httpStatus.reasonPhrase} , $errorMessage " , exception)
52
51
}
53
52
54
53
else -> {
55
- secureLogger .warn(" Exception thrown to client: ${httpStatus.reasonPhrase} , $errorMessage " , exception)
54
+ ourLogger .warn(" Exception thrown to client: ${httpStatus.reasonPhrase} , $errorMessage " , exception)
56
55
}
57
56
}
58
57
}
0 commit comments