CLI: Handle non-json responses (#1749)

This commit is contained in:
Ben Carman 2020-08-04 07:24:11 -05:00 committed by GitHub
parent db7af37ac5
commit e7b4ec5a1b

View File

@ -1062,11 +1062,11 @@ object ConsoleCli {
case Right(response) => response
}
val js = ujson.read(rawBody)
val jsObjT =
Try(js.obj).transform[mutable.LinkedHashMap[String, ujson.Value]](
Success(_),
_ => error(s"Response was not a JSON object! Got: $rawBody"))
Try(ujson.read(rawBody).obj)
.transform[mutable.LinkedHashMap[String, ujson.Value]](
Success(_),
_ => error(s"Response was not a JSON object! Got: $rawBody"))
/** Gets the given key from jsObj if it exists
* and is not null */