Network error details in Javascript

80 views
Skip to first unread message

Arnaud Cassaigne

unread,
Mar 24, 2023, 6:51:40 PM3/24/23
to Chromium-discuss
Hi,

would it be possible to get the network error detail (like ERR::CONTENT_DECODING_FAILED or other) in Javascript ?

Best regards,
Arnaud

Jon Perryman

unread,
Mar 24, 2023, 9:32:23 PM3/24/23
to arnaud.c...@mondeca.com, Chromium-discuss
Have you tried using onerror for document, window or some other object that includes (or is) the failing object?

--
--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discu...@chromium.org.

Arnaud Cassaigne

unread,
Apr 3, 2023, 5:30:22 AM4/3/23
to Chromium-discuss, Jon Perryman, Chromium-discuss, arnaud.c...@mondeca.com
Hi Jon,

thank you for your response. This is I think an old topic to access Chrome network errors in Javascript: 

Best regards,
Arnaud

Jon Perryman

unread,
Apr 3, 2023, 2:31:19 PM4/3/23
to Arnaud Cassaigne, Chromium-discuss
Hi Amaud,

The topic you cite is misleading about capturing errors.

I did a quick test using <img src="bad.jpg" onerror="console.log(event);"></img> which captures the net::ERR_FILE_NOT_FOUND

You could run the same test on the object with the error you want to capture to see if the browser is capturing the error. I suspect the error you mentioned will be captured.

Although error attributes such as error message are supposed to be available, it is unclear how to access the error object. Maybe someone else knows how to access the error object from HTML defined event listeners (as opposed to the AddEventListener method). You may need to open a problem ticket if chromium did not implement error object for HTML ONERROR.

Remember that javascript is a non-blocking language which means it cannot wait. Javascript TRY is only useful when a wait does not occur. Javascript AddEventListener method for error events and HTML ONERROR allows you to capture these errors outside javascript.

Good luck.

Jon.


Reply all
Reply to author
Forward
0 new messages