Skip to content

Commit

Permalink
refactor/catch the exception and check the error instead of check con…
Browse files Browse the repository at this point in the history
…nection status
  • Loading branch information
hongwei1 committed Oct 10, 2023
1 parent 46ebbf1 commit 116a7c8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions obp-api/src/main/scala/bootstrap/liftweb/Boot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -703,13 +703,13 @@ class Boot extends MdcLoggable {
})

LiftRules.exceptionHandler.prepend{
// case(_, r, e) if tryo(DB.use(DefaultConnectionIdentifier){ conn => conn}.isClosed).getOrElse(true) => {
// logger.error("Exception being returned to browser when processing " + r.uri.toString, e)
// JsonResponse(
// Extraction.decompose(ErrorMessage(code = 500, message = s"${ErrorMessages.DatabaseConnectionClosedError}")),
// 500
// )
// }
case(_, r, e) if e.isInstanceOf[NullPointerException] && e.getMessage.contains("Looking for Connection Identifier") => {
logger.error(s"Exception being returned to browser when processing url is ${r.request.uri}, method is ${r.request.method}, exception detail is $e", e)
JsonResponse(
Extraction.decompose(ErrorMessage(code = 500, message = s"${ErrorMessages.DatabaseConnectionClosedError}")),
500
)
}
case(Props.RunModes.Development, r, e) => {
logger.error(s"Exception being returned to browser when processing url is ${r.request.uri}, method is ${r.request.method}, exception detail is $e", e)
JsonResponse(
Expand All @@ -719,7 +719,7 @@ class Boot extends MdcLoggable {
}
case (_, r , e) => {
sendExceptionEmail(e)
logger.error("Exception being returned to browser when processing " + r.uri.toString, e)
logger.error(s"Exception being returned to browser when processing url is ${r.request.uri}, method is ${r.request.method}, exception detail is $e", e)
JsonResponse(
Extraction.decompose(ErrorMessage(code = 500, message = s"${ErrorMessages.InternalServerError}")),
500
Expand Down

0 comments on commit 116a7c8

Please sign in to comment.