Skip to content

Commit c5e0e31

Browse files
committed
feature: remove unnecessary log in case of HTTP 404
1 parent df64853 commit c5e0e31

File tree

3 files changed

+10
-25
lines changed

3 files changed

+10
-25
lines changed

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
22
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
33

44
group = "com.github.attacktive"
5-
version = "1.2.8"
5+
version = "1.2.9"
66
java.sourceCompatibility = JavaVersion.VERSION_21
77

88
plugins {

src/main/kotlin/com/github/attacktive/troubleshootereditor/common/controller/BasicErrorController.kt

-24
This file was deleted.

src/main/kotlin/com/github/attacktive/troubleshootereditor/common/controller/GlobalControllerExceptionHandler.kt

+9
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,24 @@ package com.github.attacktive.troubleshootereditor.common.controller
22

33
import com.github.attacktive.troubleshootereditor.common.extension.logger
44
import com.github.attacktive.troubleshootereditor.ingamedata.common.ErrorResponse
5+
import org.springframework.http.HttpStatus
56
import org.springframework.http.ResponseEntity
67
import org.springframework.http.converter.HttpMessageConversionException
78
import org.springframework.web.bind.annotation.ExceptionHandler
89
import org.springframework.web.bind.annotation.RestControllerAdvice
10+
import org.springframework.web.servlet.resource.NoResourceFoundException
911

1012
@RestControllerAdvice
1113
class GlobalControllerExceptionHandler {
1214
private val logger by logger()
1315

16+
@ExceptionHandler(NoResourceFoundException::class)
17+
fun handleNoResourceFoundException(exception: NoResourceFoundException): ResponseEntity<ErrorResponse> {
18+
logger.error("Resource not found: /{}", exception.resourcePath)
19+
20+
return ResponseEntity(ErrorResponse(exception), HttpStatus.NOT_FOUND)
21+
}
22+
1423
@ExceptionHandler(HttpMessageConversionException::class)
1524
fun handleHttpMessageConversionException(exception: HttpMessageConversionException): ResponseEntity<ErrorResponse> {
1625
logger.error(exception.message, exception)

0 commit comments

Comments
 (0)