File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -3218,6 +3218,7 @@ export class ErrorFromResponse<T> extends Error {
3218
3218
public code : number | null ;
3219
3219
public status : number ;
3220
3220
public response : AxiosResponse < T > ;
3221
+ public name = 'ErrorFromResponse' ;
3221
3222
3222
3223
constructor (
3223
3224
message : string ,
@@ -3236,6 +3237,29 @@ export class ErrorFromResponse<T> extends Error {
3236
3237
this . response = response ;
3237
3238
this . status = status ;
3238
3239
}
3240
+
3241
+ // Vitest helper (serialized errors are too large to read)
3242
+ // https://github.com/vitest-dev/vitest/blob/v3.1.3/packages/utils/src/error.ts#L60-L62
3243
+ toJSON ( ) {
3244
+ const extra = [
3245
+ [ 'status' , this . status ] ,
3246
+ [ 'code' , this . code ] ,
3247
+ ] as const ;
3248
+
3249
+ const joinable = [ ] ;
3250
+
3251
+ for ( const [ key , value ] of extra ) {
3252
+ if ( typeof value !== 'undefined' && value !== null ) {
3253
+ joinable . push ( `${ key } : ${ value } ` ) ;
3254
+ }
3255
+ }
3256
+
3257
+ return {
3258
+ message : `(${ joinable . join ( ', ' ) } ) - ${ this . message } ` ,
3259
+ stack : this . stack ,
3260
+ name : this . name ,
3261
+ } ;
3262
+ }
3239
3263
}
3240
3264
3241
3265
export type QueryPollsResponse = {
You can’t perform that action at this time.
0 commit comments