scalajs getCause在Ajax.post onFailure上

问题描述 投票:2回答:1

尝试获取Ajax.post失败的原因(使用Scala.Js),但只获取类名:

Ajax.post(
  url = "...",
  data = "...",
  headers = Map("Content-Type"->"application/json; charset=utf-8",
                "Csrf-Token" -> "...")
).map(_.responseText).map(
  content => content match {
    case _                  => ...
  }
).onFailure {
  case err => log.info(s"failure ${err.toString} ${err.getCause} ${err.getMessage}")
}

我明白了:

failure org.scalajs.dom.ext.AjaxException null null

有可能得到原因吗?谢谢

ajax post error-handling scala.js
1个回答
0
投票

我不这么认为。因为AjaxException不能用一个原因构建:

case class AjaxException(xhr: dom.XMLHttpRequest) extends Exception {
  def isTimeout = xhr.status == 0 && xhr.readyState == 4
}
© www.soinside.com 2019 - 2024. All rights reserved.