File tree 2 files changed +7
-4
lines changed
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ fetch('http://example.com/posts', {
79
79
return res .json ()
80
80
}
81
81
82
- throw new Error (' Oops ' )
82
+ throw new Error (' Request failed ' )
83
83
})
84
84
```
85
85
@@ -105,7 +105,7 @@ fetch('http://example.com/posts?id=1').then((res) => {
105
105
return res .json ()
106
106
}
107
107
108
- throw new Error (' Oops ' )
108
+ throw new Error (' Request failed ' )
109
109
})
110
110
```
111
111
@@ -193,7 +193,7 @@ fetch('http://example.com/posts', {
193
193
return res .json ()
194
194
}
195
195
196
- throw new Error (' Oops ' )
196
+ throw new Error (' Request failed ' )
197
197
})
198
198
.catch ((error ) => {
199
199
if (error .name === ' AbortError' ) {
Original file line number Diff line number Diff line change @@ -198,7 +198,10 @@ class ResponseError<P extends Payload = Payload> extends Error {
198
198
name = 'ResponseError'
199
199
response : Response < P >
200
200
201
- constructor ( response : Response < P > , message = response . statusText ) {
201
+ constructor (
202
+ response : Response < P > ,
203
+ message : string = `Request failed with status code ${ response . status } `
204
+ ) {
202
205
super ( message )
203
206
this . response = response
204
207
}
You can’t perform that action at this time.
0 commit comments