diff --git a/exception-handler-spring-web/src/main/kotlin/ru/touchin/exception/handler/dto/ExceptionResolverResult.kt b/exception-handler-spring-web/src/main/kotlin/ru/touchin/exception/handler/dto/ExceptionResolverResult.kt index 5408aa9..68f43db 100644 --- a/exception-handler-spring-web/src/main/kotlin/ru/touchin/exception/handler/dto/ExceptionResolverResult.kt +++ b/exception-handler-spring-web/src/main/kotlin/ru/touchin/exception/handler/dto/ExceptionResolverResult.kt @@ -8,6 +8,7 @@ data class ExceptionResolverResult( val apiError: ApiError, val status: HttpStatus, val exception: Exception?, + val includeHeaders: Boolean = false, ) { companion object { diff --git a/exception-handler-spring-web/src/main/kotlin/ru/touchin/exception/handler/spring/advices/ExceptionHandlerAdvice.kt b/exception-handler-spring-web/src/main/kotlin/ru/touchin/exception/handler/spring/advices/ExceptionHandlerAdvice.kt index c3675c0..8b24bb7 100644 --- a/exception-handler-spring-web/src/main/kotlin/ru/touchin/exception/handler/spring/advices/ExceptionHandlerAdvice.kt +++ b/exception-handler-spring-web/src/main/kotlin/ru/touchin/exception/handler/spring/advices/ExceptionHandlerAdvice.kt @@ -31,10 +31,10 @@ class ExceptionHandlerAdvice( val body = exceptionResponseBodyCreator(result.apiError) - val headers = HttpHeaders().apply { + val headers = if (result.includeHeaders) HttpHeaders().apply { set("X-Error-Code", result.apiError.errorCode.toString()) set("X-Error-Message", result.apiError.errorMessage) - } + } else null return ResponseEntity(body, headers, result.status) }