@@ -49,7 +49,7 @@ export const instance = async <I, R>(
4949 input : URL | RequestInfo ,
5050 init ?: InitType < I > ,
5151 error ?: Record < string , Error > ,
52- ) : Promise < R | void > => {
52+ ) : Promise < R > => {
5353 let cookieHeader = '' ;
5454 if ( typeof window === 'undefined' ) {
5555 cookieHeader = ( await import ( 'next/headers' ) ) . cookies ( ) . toString ( ) ;
@@ -77,26 +77,26 @@ export const instance = async <I, R>(
7777 const context = err as Response ;
7878 if ( location && ! context . ok && context . status === 401 ) {
7979 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 ( ) ;
8089 } 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 ;
9996 }
97+
98+ captureException ( error [ `${ ( err as Response ) . status } ` ] ) ;
99+ throw error [ `${ ( err as Response ) . status } ` ] ;
100100 }
101101 }
102102} ;
0 commit comments