Closed bernhardreiter closed 8 months ago
This may be not possible:
error.message
of Failed to fetch
error.message
of NetworkError when attempting to fetch resource.
which both does not allow to differentiate further although the documentation suggests otherwise.
Having looked at Stack Overflow I found this:
As a client of fetch, you can't differentiate network errors from other errors caused by building an incorrect request, as both are thrown as TypeErrors. (See https://developer.mozilla.org/en-US/docs/Web/API/fetch#exceptions). This is quite a flaw, as application defects that cause an incorrectly built request may go unnoticed, masked as if they were circumstantial network errors.
Which basically says the same I experienced. So I leave a "general" error handler for these cases.
But otherwise implemented messages distinguishing between the typical 401
, 403
, 404
.
Meanwhile improved by @ThomasJunk by dealing with response code. @JanHoefelmeyer did you test that other error message work already?
Error-responses will be handled as expected:
An error will cause an error Text to appear, detailing the status code and statustext (if any).
According to https://developer.mozilla.org/en-US/docs/Web/API/fetch we need to deal with exceptions and with different response codes in case response.ok == false.
Dot get done in
lib/urloader.ts