Add debug exception resolver for troubleshooting
All checks were successful
build-and-deploy / build-deploy (push) Successful in 27s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 27s
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
package com.android.trisolarisserver.config
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest
|
||||||
|
import jakarta.servlet.http.HttpServletResponse
|
||||||
|
import org.springframework.stereotype.Component
|
||||||
|
import org.springframework.web.servlet.HandlerExceptionResolver
|
||||||
|
import org.springframework.web.servlet.ModelAndView
|
||||||
|
|
||||||
|
@Component
|
||||||
|
class DebugExceptionResolver : HandlerExceptionResolver {
|
||||||
|
override fun resolveException(
|
||||||
|
request: HttpServletRequest,
|
||||||
|
response: HttpServletResponse,
|
||||||
|
handler: Any?,
|
||||||
|
ex: Exception
|
||||||
|
): ModelAndView? {
|
||||||
|
if (request.getHeader("X-Debug-Auth") == "1" && !response.isCommitted) {
|
||||||
|
val msg = ex.message?.take(200) ?: ""
|
||||||
|
response.setHeader("X-Exception", "${ex::class.java.simpleName}:$msg")
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user