无法加载 play.http.errorHandler - 未调用自定义处理程序
Cannot load play.http.errorHandler - custom handler not invoked
我正尝试按照 the documentation 在 Play Framework (2.6) 中加载自定义错误处理程序,但收到以下错误消息 -
Cannot load play.http.errorHandler
自定义错误处理程序(app/services/ErrorHandler)
package services
import javax.inject.Singleton
import play.api.http.HttpErrorHandler
import play.api.mvc.Results._
import play.api.mvc._
import scala.concurrent._
@Singleton
class ErrorHandler extends HttpErrorHandler {
def onClientError(request: RequestHeader, statusCode: Int, message: String) = {
Future.successful(
Status(statusCode)(
message
)
)
}
def onServerError(request: RequestHeader, exception: Throwable) = {
Future.successful(
InternalServerError("A server errors occurred: " + exception.getMessage)
)
}
}
application.conf
play.http.errorHandler = "com.mySite.services.ErrorHandler"
在您的代码中,包不是 com.mySite.services
。只是 services
.
application.conf
play.http.errorHandler = "services.ErrorHandler"
我正尝试按照 the documentation 在 Play Framework (2.6) 中加载自定义错误处理程序,但收到以下错误消息 -
Cannot load play.http.errorHandler
自定义错误处理程序(app/services/ErrorHandler)
package services
import javax.inject.Singleton
import play.api.http.HttpErrorHandler
import play.api.mvc.Results._
import play.api.mvc._
import scala.concurrent._
@Singleton
class ErrorHandler extends HttpErrorHandler {
def onClientError(request: RequestHeader, statusCode: Int, message: String) = {
Future.successful(
Status(statusCode)(
message
)
)
}
def onServerError(request: RequestHeader, exception: Throwable) = {
Future.successful(
InternalServerError("A server errors occurred: " + exception.getMessage)
)
}
}
application.conf
play.http.errorHandler = "com.mySite.services.ErrorHandler"
在您的代码中,包不是 com.mySite.services
。只是 services
.
application.conf
play.http.errorHandler = "services.ErrorHandler"