@@ -151,29 +151,34 @@ async function resolve(uri: string, options?: ResolveOptions): Promise<ResolveOu
151151 // create a promise to each gateway
152152 const promises = gateways . map ( async ( gatewayUrl , i ) : Promise < ResolveOutput > => {
153153
154- // create an abort controller to stop the fetch requests when the first one is resolved.
155- const controller = new AbortController ( ) ;
156- const signal = controller . signal ;
157- abortControllers [ i ] = controller ;
158-
159- const urlResolvedFrom = `${ gatewayUrl } ${ gatewaySuffix } ` ;
160- const response = await _options . fetchOverride ( urlResolvedFrom , {
161- method : "get" ,
162- signal,
163- } as RequestInit ) ;
164-
165- // remove the abort controller for the completed response
166- abortControllers [ i ] = undefined ;
167-
168- // check the response because a lot of gateways will do redirects and other checks which will not be compatible
169- // with this library
170- if ( response . status >= 300 || response . status < 200 ) {
171- throw new Error ( `Url (${ urlResolvedFrom } ) did not return a 2xx response` ) ;
172- }
173-
174- return {
175- response,
176- urlResolvedFrom
154+ try {
155+ // create an abort controller to stop the fetch requests when the first one is resolved.
156+ const controller = new AbortController ( ) ;
157+ const signal = controller . signal ;
158+ abortControllers [ i ] = controller ;
159+
160+ const urlResolvedFrom = `${ gatewayUrl } ${ gatewaySuffix } ` ;
161+ const response = await _options . fetchOverride ( urlResolvedFrom , {
162+ method : "get" ,
163+ signal,
164+ } as RequestInit ) ;
165+
166+ // remove the abort controller for the completed response
167+ abortControllers [ i ] = undefined ;
168+
169+ // check the response because a lot of gateways will do redirects and other checks which will not be compatible
170+ // with this library
171+ if ( response . status >= 300 || response . status < 200 ) {
172+ throw new Error ( `Url (${ urlResolvedFrom } ) did not return a 2xx response` ) ;
173+ }
174+
175+ return {
176+ response,
177+ urlResolvedFrom
178+ }
179+ } catch ( err ) {
180+ console . error ( gatewayUrl , err ) ;
181+ throw err ;
177182 }
178183 } )
179184
0 commit comments