Skip to content

Commit

Permalink
Fix error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderfefelov committed Mar 20, 2019
1 parent 54d1388 commit edd21ac
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,18 @@ class KkmServerApi extends Instrumented {
logger.debug(s"request: $requestJson")
val responseFuture = wsCall(requestJson)
for {
response <- responseFuture
response <- responseFuture recoverWith {
case e: Exception =>
val message = s"${e.getClass.getName}: ${e.getMessage}"
logger.error(s"error: $message")
throw KkmServerApiException(message)
}
} yield {
if (response.statusCode != 200) {
val message = s"KkmServer response: ${response.statusCode} ${response.statusMessage}"
logger.error(s"error: $message")
throw KkmServerApiException(message)
}
val responseText = response.text(Charset.forName("UTF-8"))
logger.debug(s"response: $responseText")
try {
Expand Down

0 comments on commit edd21ac

Please sign in to comment.