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
I've already run into bugs twice before due to messing up the
boilerplate code that was previously necessary. This abstraction makes
the interface for API error handling much more simple (and therefore
robust). It's not perfect, but it solves the problem.
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- We don't have an accurate type for this, and using `unknown` would require many pointless type assertions or runtime checks.
// The default is `cancel`, but canceling previous requests doesn't stop the
27
21
// backend from processing them. This lets any previous request finish and
28
22
// reuses it, which is quicker and more reliable since it already started.
29
23
dedupe: "defer",
30
24
31
-
onRequestError(ctx){
32
-
errorBoxes.handleError(ctx.error);
33
-
},
34
-
35
-
onResponseError(ctx){
36
-
consterror=createFetchError(ctx);
37
-
38
-
if(shouldIgnoreResponseError?.(error)){
39
-
return;
40
-
}
41
-
42
-
errorBoxes.handleError(error);
43
-
},
44
-
45
25
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- The error from removing this assertion is too convoluted for me to decipher, and I see no reason this shouldn't work at runtime.
0 commit comments