Re: [whatwg/fetch] More informative error types (#526)

a-smith-48761 left a comment (whatwg/fetch#526)

> Unfortunately I missed the nuance in the more recent replies that are not asking for more granularity but instead are asking for distinguishing the exception when you are further away from the caller. I suppose one thing we could do is try to standardize the `message` value. Looking at https://github.com/sindresorhus/is-network-error/blob/main/index.js Chromium's "`Failed to fetch`" seems pretty reasonable.
> 
> That's not a great solution, but it's an improvement.
> 
> I'm not entirely sure what a great solution would look like.

From my perspective, I think a great solution would look like an option that could be passed that would cause fetch to produce a new exception type that provides all the possible information. Then new users could pass that option and handle the new exception (along with best effort attempt at handling old exception types where required -- this could even be delegated to a compatibility layer that converts the old exceptions to the new ones), while legacy users could still rely on getting the existing exception types.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/526#issuecomment-4143596314
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/issues/526/4143596314@github.com>

Received on Friday, 27 March 2026 15:57:52 UTC