If I got this right, then you're saying you're receiving data which is not
valid JSON?

The trick there is that there's a 'failure' and 'error' handler: the one
('failure') is for processing HTTP response codes, such as, for example,
403, instead of the desired 200. Basically, that's the Request 'failure'
event. The other error event handler (event: 'error') is there to process
any JSON parse failures.

If this is a 'how do I debug/trace a Request' question however, than the way
to go is to set breakpoints in the handlers (onSuccess, onFailure, ...)
which you've bound to the Request events (e.g. instance.addEvents({success:
..., failure: ..., error: ....}); ) before in the code. Simply stepping
through (Firebug: F10/F11) won't do it for you as these are asynchronous
events.


Re the first para of my response: see also the source code of Core:
Request/Request.js and Core: Request/Request.JSON.js: note that JSON
failures will also fire the 'failure' event, next to the 'error' event (if
my understanding of the Request.JSON.js code is correct):

success: function(text){

var json;

try {

json = this.response.json = JSON.decode(text, this.options.secure);

} catch (error){

this.fireEvent('error', [text, error]);

return;

}

if (json == null) this.onFailure();

else this.onSuccess(json, text);

}







On Fri, Apr 8, 2011 at 2:06 AM, bootle <[email protected]> wrote:

> Hey guys,
>
> I'm building an extension of the Request class, that among others will
> handle various errors.
>
> I found a problem which could be a bug in the Request class.
>
> When I use Request.JSON to access HTML content (deliberately), let's
> say 'http://google.com' I think it should return an error (onFailure
> or onException?).
> What happens is the request 'dies' after onRequest and no other event
> is fired, even though the request finishes and I can see returned HTML
> content in FireBug.
>
> Is there any way to catch such error?
>
> Thanks!
> Matt




-- 
Met vriendelijke groeten / Best regards,

Ger Hobbelt

--------------------------------------------------
web:    http://www.hobbelt.com/
        http://www.hebbut.net/
mail:   [email protected]
mobile: +31-6-11 120 978
--------------------------------------------------

Reply via email to