@@ -49,7 +49,7 @@ export const instance = async <I, R>(
49
49
input : URL | RequestInfo ,
50
50
init ?: InitType < I > ,
51
51
error ?: Record < string , Error > ,
52
- ) : Promise < R | void > => {
52
+ ) : Promise < R > => {
53
53
let cookieHeader = '' ;
54
54
if ( typeof window === 'undefined' ) {
55
55
cookieHeader = ( await import ( 'next/headers' ) ) . cookies ( ) . toString ( ) ;
@@ -77,26 +77,26 @@ export const instance = async <I, R>(
77
77
const context = err as Response ;
78
78
if ( location && ! context . ok && context . status === 401 ) {
79
79
window . location . replace ( '/' ) ;
80
+ return { } as never ;
81
+ }
82
+ setContext ( 'Request' , {
83
+ path : context . url ,
84
+ status : context . status ,
85
+ } ) ;
86
+ if ( ( err as Error ) . name === 'TimeoutError' ) {
87
+ captureException ( new ServerNotRespondingError ( ) ) ;
88
+ throw new ServerNotRespondingError ( ) ;
80
89
} else {
81
- setContext ( 'Request' , {
82
- path : context . url ,
83
- status : context . status ,
84
- } ) ;
85
- if ( ( err as Error ) . name === 'TimeoutError' ) {
86
- captureException ( new ServerNotRespondingError ( ) ) ;
87
- throw new ServerNotRespondingError ( ) ;
88
- } else {
89
- if ( ! error ?. [ `${ ( err as Response ) . status } ` ] ) {
90
- const serverError = new Error (
91
- `서버에서 예기치 않은 오류가 발생했습니다. (${ ( err as Error ) . name } )` ,
92
- ) ;
93
- captureException ( serverError ) ;
94
- throw serverError ;
95
- }
96
-
97
- captureException ( error [ `${ ( err as Response ) . status } ` ] ) ;
98
- throw error [ `${ ( err as Response ) . status } ` ] ;
90
+ if ( ! error ?. [ `${ ( err as Response ) . status } ` ] ) {
91
+ const serverError = new Error (
92
+ `서버에서 예기치 않은 오류가 발생했습니다. (${ ( err as Error ) . name } )` ,
93
+ ) ;
94
+ captureException ( serverError ) ;
95
+ throw serverError ;
99
96
}
97
+
98
+ captureException ( error [ `${ ( err as Response ) . status } ` ] ) ;
99
+ throw error [ `${ ( err as Response ) . status } ` ] ;
100
100
}
101
101
}
102
102
} ;
0 commit comments