Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def handleResponseWithRecover[T](response: Future[WSResponse], success: WSResponse => T): Future[T] = {
- response.map { resp =>
- if (!Status.isSuccessful(resp.status)) {
- logger.warn(s"Error from ${serviceName} - status '${resp.status}' on '${resp.uri}' with body '${resp.body}' ")
- }
- success(resp)
- }.recover {
- case rse: RemoteServerException =>
- logger.error(s"Error response from $serviceName - ${rse.error}", rse)
- throw rse
- case t: Throwable =>
- logger.error(s"Internal server error when contacting $serviceName ${t.getMessage}", t)
- throw InternalServerException("error.unexpected", s"${t.getMessage}", t)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment