From cb9960e27b529874b73b8cf82d93a6913d1b69c3 Mon Sep 17 00:00:00 2001 From: Otto Chrons Date: Sat, 21 Feb 2015 19:19:40 +0200 Subject: [PATCH] Added a method to AjaxException to check for timeout status. --- src/main/scala/org/scalajs/dom/ext/Extensions.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/scala/org/scalajs/dom/ext/Extensions.scala b/src/main/scala/org/scalajs/dom/ext/Extensions.scala index c8300f4a6..be6c8159a 100644 --- a/src/main/scala/org/scalajs/dom/ext/Extensions.scala +++ b/src/main/scala/org/scalajs/dom/ext/Extensions.scala @@ -154,9 +154,12 @@ object KeyCode { import scala.concurrent.{Promise, Future} /** * Thrown when `Ajax.get` or `Ajax.post` receives a non-20X response code. - * Contains the XMLHttpRequest that resulted in that respons + * Contains the XMLHttpRequest that resulted in that response */ -case class AjaxException(xhr: dom.XMLHttpRequest) extends Exception +case class AjaxException(xhr: dom.XMLHttpRequest) extends Exception { + def isTimeout = xhr.status == 0 && xhr.readyState == 4 +} + /** * Wraps an XMLHttpRequest to provide an easy one-line way of making * an Ajax call, returning a Future.