Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fetch API or XMLHTTPRequest: How to get exact error reason for a network error? [duplicate]

How to retrieve exact information about a network error? Chrome browser prints things like "net::ERR_CONNECTION_TIMED_OUT" or "net::ERR_CERT_INVALID" into console but how can I retrieve them via JS? Is that possible to get them at all? Currently I use fetch API but I can switch to XMLHTTPRequest easily.

I need that to handle such errors to inform a user and let him know what does he need to do.

like image 993
Andrey Gubanov Avatar asked Nov 16 '22 21:11

Andrey Gubanov


1 Answers

This information is intentionally inaccessible from JavaScript to prevent security issues.

Here is a Chromium bug report requesting this functionality in May 2017: https://bugs.chromium.org/p/chromium/issues/detail?id=718447

like image 129
Tate Thurston Avatar answered May 29 '23 06:05

Tate Thurston