error handling in Gears file upload?

4 views
Skip to first unread message

Garret

unread,
Nov 10, 2008, 1:16:07 AM11/10/08
to Gears Users
I'm very excited about the file upload capabilities in Gears. But
reading the documentation at http://code.google.com/apis/gears/api_httprequest.html
, I can't figure out how error handling occurs.

* How is an error reported for a file upload? For example, if I pull
out my Ethernet cable in the middle of an upload, how is this
reported? Does the readyState go to 4 (complete)?

* How is canceling reported for a file upload? If I manually cancel
the upload, does the readyState still go to 4 (complete) and I have to
check to some flag to see if the upload was canceled?

Thanks,

Garret

Austin

unread,
Nov 10, 2008, 6:01:03 PM11/10/08
to gears...@googlegroups.com
Hi,

Gears HttpRequest API is intentionally designed to minic XHR and thus carries the same fate when it comes to network level errors.  XHR does not provide network level errors to the caller in a particularly direct fashion. The hope is that XHR2 spec will attempt to clarify these sort of needs.  

Hope that helps,
Austin

Garret Wilson

unread,
Nov 10, 2008, 11:45:26 PM11/10/08
to Gears Users
Austin,

Thanks for the reply, but it was terribly vague.

"...thus carries the same fate..."---what fate is that?

"...in a particularly direct fashion."---what particular fashion is
it, then?

Perhaps the "fate" isn't "particularly direct", but surely *something*
happens. I need to know what that "something" is, because it isn't
documented.

* When a network error occurs, what does the readyState change to?

* When a network error occurs, is onprogress() called, and with what
values?

* When I cancel an upload, what does the readyState change to?

* When I cancel an upload, is onprogress() called, and with what
values?

Regardless of whether XHR is well documented, Gears is a Google
produce that presumably has some deterministic behavior in the
presence of errors. Why can't that be documented?

Garret

Michael Nordman

unread,
Nov 10, 2008, 11:56:04 PM11/10/08
to gears...@googlegroups.com
Hi Garret, 

The request object transitions to the 'complete' ready state (4) and the req.status property accessor will throw an exception after the request has completed due to a network error or an explicit call to abort.

Garret Wilson

unread,
Nov 11, 2008, 12:10:56 AM11/11/08
to Gears Users
Michael,

Actually, while I was waiting I did a test---I can successfully cancel
an upload, but I get no ready state change after I manually abort.

Garret

Garret Wilson

unread,
Nov 11, 2008, 1:57:32 AM11/11/08
to Gears Users
OK, file upload seems to be working for me. I've presented
instructions for file upload using Google Gears here:

http://www.garretwilson.com/blog/2008/11/10/googlegearsfileupload.xhtml

Thanks for the responses.

Garret

Michael Nordman

unread,
Nov 11, 2008, 2:25:39 PM11/11/08
to gears...@googlegroups.com
On Mon, Nov 10, 2008 at 9:10 PM, Garret Wilson <gar...@globalmentor.com> wrote:

Michael,

Actually, while I was waiting I did a test---I can successfully cancel
an upload, but I get no ready state change after I manually abort.

Right... in looking a our implementation it won't fire an readystatechanged event in the abort case, although it should depending on the state at the time the abort method is called...  http://www.w3.org/TR/XMLHttpRequest/#abort
  1. Abort the send() algorithm, set the response entity body to "null", the error flag to "true" and remove any registered request headers.

  2. The user agent should cancel any network activity for which the object is responsible.

  3. If the state is UNSENTOPENED and the send() flag is "false", or DONE go to the next step.

    Otherwise, switch the state to DONE, set the send() flag to "false" and synchronously dispatch a readystatechange event on the object.

  4. Switch the state to UNSENT. (Do not dispatch the readystatechange event.)


Reply all
Reply to author
Forward
0 new messages