Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ dependencies {
compileOnly("org.springframework.boot:spring-boot-starter-validation")

implementation("jakarta.annotation:jakarta.annotation-api")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("tools.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")

testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.boot:spring-boot-webtestclient")
testImplementation("org.springframework.cloud:spring-cloud-contract-wiremock")
testImplementation("org.springframework.cloud:spring-cloud-starter-openfeign")
testImplementation("org.springframework.boot:spring-boot-starter-web")
Expand All @@ -56,8 +57,8 @@ extra["kotlin.version"] = "2.4.0"

dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:3.5.15")
mavenBom("org.springframework.cloud:spring-cloud-dependencies:2025.0.3")
mavenBom("org.springframework.boot:spring-boot-dependencies:4.1.0")
mavenBom("org.springframework.cloud:spring-cloud-dependencies:2025.1.2")
}
}

Expand Down
7 changes: 0 additions & 7 deletions src/main/kotlin/com/valensas/exception/ApiException.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ open class Processing(
data: HashMap<*, *>? = null
) : ApiException(message, code, data)

@ResponseStatus(HttpStatus.CHECKPOINT)
open class CheckPoint(
message: String,
code: String = "CHECKPOINT",
data: HashMap<*, *>? = null
) : ApiException(message, code, data)

@ResponseStatus(HttpStatus.OK)
open class Ok(
message: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.valensas.exception.autoconfigure

import com.fasterxml.jackson.databind.ObjectMapper
import com.valensas.exception.ApiException
import com.valensas.exception.ParameterException
import com.valensas.exception.handler.ApiExceptionErrorHandler
Expand All @@ -18,6 +17,7 @@ import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.web.client.RestTemplate
import org.springframework.web.reactive.function.client.WebClient
import tools.jackson.databind.ObjectMapper

@Configuration
@RegisterReflectionForBinding(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.valensas.exception.handler

import com.fasterxml.jackson.databind.ObjectMapper
import com.valensas.exception.ApiException
import com.valensas.exception.autoconfigure.ExceptionHandlerConfigurationProperties
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RestControllerAdvice
import tools.jackson.databind.ObjectMapper

@RestControllerAdvice
class ApiExceptionErrorHandler(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.valensas.exception.handler

import com.fasterxml.jackson.databind.ObjectMapper
import com.valensas.exception.ApiException
import com.valensas.exception.autoconfigure.ExceptionHandlerConfigurationProperties
import feign.FeignException
Expand All @@ -11,6 +10,7 @@ import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RestControllerAdvice
import tools.jackson.databind.ObjectMapper

@RestControllerAdvice
class FeignErrorHandler(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.valensas.exception.handler

import com.fasterxml.jackson.databind.ObjectMapper
import com.valensas.exception.ApiException
import com.valensas.exception.ParameterException
import org.slf4j.LoggerFactory
import org.springframework.http.HttpHeaders
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import tools.jackson.databind.ObjectMapper

abstract class HttpErrorHandler(
protected val mapper: ObjectMapper,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.valensas.exception.handler

import com.fasterxml.jackson.databind.ObjectMapper
import com.valensas.exception.ApiException
import com.valensas.exception.autoconfigure.ExceptionHandlerConfigurationProperties
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass
Expand All @@ -10,6 +9,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RestControllerAdvice
import org.springframework.web.client.HttpStatusCodeException
import org.springframework.web.client.RestTemplate
import tools.jackson.databind.ObjectMapper

@RestControllerAdvice
@ConditionalOnClass(RestTemplate::class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.valensas.exception.handler

import com.fasterxml.jackson.databind.ObjectMapper
import com.valensas.exception.ApiException
import com.valensas.exception.autoconfigure.ExceptionHandlerConfigurationProperties
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RestControllerAdvice
import org.springframework.web.reactive.function.client.WebClientResponseException
import tools.jackson.databind.ObjectMapper

@RestControllerAdvice
class WebClientErrorHandler(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.valensas.exception.handler

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.exc.MismatchedInputException
import com.valensas.exception.FieldError
import com.valensas.exception.ParameterErrorCode
import com.valensas.exception.ParameterException
Expand All @@ -17,6 +15,8 @@ import org.springframework.web.bind.support.WebExchangeBindException
import org.springframework.web.method.annotation.HandlerMethodValidationException
import org.springframework.web.server.MissingRequestValueException
import org.springframework.web.server.ServerWebInputException
import tools.jackson.databind.ObjectMapper
import tools.jackson.databind.exc.MismatchedInputException

@RestControllerAdvice
class WebFluxParameterExceptionErrorHandler(
Expand Down Expand Up @@ -75,7 +75,7 @@ class WebFluxParameterExceptionErrorHandler(
val mismatchedInputException = decodingException.cause as MismatchedInputException
parameter =
mismatchedInputException.path.joinToString(".") {
it.fieldName ?: "[${it.index}]"
it.propertyName ?: "[${it.index}]"
}
message = mismatchedInputException.originalMessage
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.valensas.exception.handler

import com.fasterxml.jackson.databind.ObjectMapper
import com.valensas.exception.FieldError
import com.valensas.exception.ParameterErrorCode
import com.valensas.exception.ParameterException
Expand All @@ -15,6 +14,7 @@ import org.springframework.web.bind.MissingServletRequestParameterException
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RestControllerAdvice
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException
import tools.jackson.databind.ObjectMapper

@RestControllerAdvice
class WebParameterExceptionErrorHandler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.webtestclient.autoconfigure.AutoConfigureWebTestClient
import org.springframework.http.HttpStatus
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.web.reactive.server.WebTestClient
Expand All @@ -14,6 +15,7 @@ import java.util.UUID
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@ActiveProfiles("test")
@AutoConfigureWebTestClient
class WebParameterExceptionErrorHandlerTest {
@Autowired lateinit var webClient: WebTestClient

Expand Down
Loading