mirror of
https://github.com/corda/corda.git
synced 2024-12-25 23:51:10 +00:00
Added an exception mapper that prints out errors emitted by the webserver (#484)
Added an exception mapper that prints out errors emitted by the JAX-RS server to aid debugging.
This commit is contained in:
parent
23224fc92c
commit
a93692e434
webserver/src/main/kotlin/net/corda/webserver/internal
@ -1,13 +1,12 @@
|
||||
package net.corda.webserver.internal
|
||||
|
||||
import net.corda.core.messaging.CordaRPCOps
|
||||
import net.corda.webserver.api.*
|
||||
import net.corda.webserver.api.APIServer
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import javax.ws.rs.core.Response
|
||||
|
||||
class APIServerImpl(val rpcOps: CordaRPCOps) : APIServer {
|
||||
|
||||
override fun serverTime(): LocalDateTime {
|
||||
return LocalDateTime.ofInstant(rpcOps.currentNodeTime(), ZoneId.of("UTC"))
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package net.corda.webserver.internal
|
||||
|
||||
import net.corda.core.utilities.loggerFor
|
||||
import javax.ws.rs.core.Response
|
||||
import javax.ws.rs.ext.ExceptionMapper
|
||||
import javax.ws.rs.ext.Provider
|
||||
|
||||
// Provides basic exception logging to all APIs
|
||||
@Provider
|
||||
class AllExceptionMapper: ExceptionMapper<Exception> {
|
||||
companion object {
|
||||
val logger = loggerFor<APIServerImpl>()
|
||||
}
|
||||
|
||||
override fun toResponse(exception: Exception?): Response {
|
||||
logger.error("Unhandled exception in API", exception)
|
||||
return Response.status(500).build()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user