You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The goal is to catch any network error. So fetchError seems to be the correct way to do that. I have my code like:
constres=awaitwretch('https://www.example.com/404').get().fetchError(error=>{console.log('error from fetchError')}).text()
This throws a HTTP 404, so it should have been available in fetchError. But, it's not. It throws an uncaught exception. Based on this comment: #111 (comment), this seems to be expected behaviour. So, I'm just supposed to move my fetchError to the end, except that doesn't work:
I get "Unresolved function or method fetchError()".
So, I tried to use catch() after my text(). But that breaks my response as my response now gets string | void type. I then have to check for the response everytime before processing. Furthermore, I don't get the status code as error.status if I use catch().
I'm sure I'm mixing up some concepts and confusing myself, but all I need is:
Catch only network errors
Capture the status code received from the server
Keep my response type intact (not add a void type)
What am I missing?
The text was updated successfully, but these errors were encountered:
.fetchError() is used to catch errors thrown by the fetch function itself, including "network errors" which are related to habing issues reaching the server (being offline for instance) - and they are unrelated to http codes.
Hey! Thanks so much for working on this project, it's a lifesaver!
Regarding the issue, I have referred to:
#162
#111
#62
The goal is to catch any network error. So
fetchError
seems to be the correct way to do that. I have my code like:This throws a HTTP 404, so it should have been available in
fetchError
. But, it's not. It throws an uncaught exception. Based on this comment: #111 (comment), this seems to be expected behaviour. So, I'm just supposed to move myfetchError
to the end, except that doesn't work:I get "Unresolved function or method fetchError()".
So, I tried to use
catch()
after mytext()
. But that breaks my response as my response now getsstring | void
type. I then have to check for the response everytime before processing. Furthermore, I don't get the status code aserror.status
if I usecatch()
.I'm sure I'm mixing up some concepts and confusing myself, but all I need is:
void
type)What am I missing?
The text was updated successfully, but these errors were encountered: