From 6a08c4568b161a3f7b3bc2a9e372af0bfc55d41f Mon Sep 17 00:00:00 2001 From: Mikhail Yasnov Date: Wed, 16 Jun 2021 21:42:07 +0300 Subject: [PATCH] Simplify conditional expression --- exception-handler-spring-web/build.gradle.kts | 1 + .../spring/resolvers/NotFoundExceptionResolver.kt | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/exception-handler-spring-web/build.gradle.kts b/exception-handler-spring-web/build.gradle.kts index 1e7ec3a..74988d5 100644 --- a/exception-handler-spring-web/build.gradle.kts +++ b/exception-handler-spring-web/build.gradle.kts @@ -6,6 +6,7 @@ plugins { dependencies { api(project(":common")) + api(project(":common-spring")) api(project(":common-spring-web")) implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") diff --git a/exception-handler-spring-web/src/main/kotlin/ru/touchin/exception/handler/spring/resolvers/NotFoundExceptionResolver.kt b/exception-handler-spring-web/src/main/kotlin/ru/touchin/exception/handler/spring/resolvers/NotFoundExceptionResolver.kt index 24ca6a1..13b81d4 100644 --- a/exception-handler-spring-web/src/main/kotlin/ru/touchin/exception/handler/spring/resolvers/NotFoundExceptionResolver.kt +++ b/exception-handler-spring-web/src/main/kotlin/ru/touchin/exception/handler/spring/resolvers/NotFoundExceptionResolver.kt @@ -1,21 +1,21 @@ package ru.touchin.exception.handler.spring.resolvers -import org.springframework.core.Ordered import org.springframework.core.annotation.Order import org.springframework.stereotype.Component import ru.touchin.common.exceptions.CommonNotFoundException +import ru.touchin.common.spring.Ordered import ru.touchin.exception.handler.dto.ExceptionResolverResult -@Order(Ordered.LOWEST_PRECEDENCE - 1) +@Order(Ordered.LOW) @Component class NotFoundExceptionResolver : ExceptionResolver { override fun invoke(exception: Exception): ExceptionResolverResult? { - return if (exception is CommonNotFoundException) { + if (exception !is CommonNotFoundException) { ExceptionResolverResult.createNotFoundError(exception) - } else { - null } + + return null } }