@@ -11,6 +11,15 @@ import fetchEnhanced from "fetch-enhanced";
11
11
const fetch = fetchEnhanced ( undiciFetch , { undici : true } ) ;
12
12
const clone = cloner ( ) ;
13
13
14
+ async function doFetch ( url , opts ) {
15
+ try {
16
+ return await fetch ( url , opts ) ;
17
+ } catch ( err ) {
18
+ err . message = `${ err . message } (${ url } )` ;
19
+ throw err ;
20
+ }
21
+ }
22
+
14
23
async function extract ( res ) {
15
24
const styleUrls = [ ] ;
16
25
const styleTags = [ ] ;
@@ -106,7 +115,7 @@ async function extensionCss({crx, contentScriptsOnly, strict}) {
106
115
url += `&x=id%3D${ crx } ` ;
107
116
url += `%26uc` ;
108
117
109
- const res = await fetch ( url ) ;
118
+ const res = await doFetch ( url ) ;
110
119
validateStatus ( res , url , strict ) ;
111
120
112
121
const crxBuffer = arrayBufferToBufferCycle ( await res . arrayBuffer ( ) ) ;
@@ -176,7 +185,7 @@ export default async function fetchCss(sources) { // eslint-disable-line import/
176
185
const sourceResponses = await Promise . all ( sources . map ( source => {
177
186
if ( ! source . url ) return null ;
178
187
const { pathname} = new URL ( source . url ) ;
179
- return pathname . endsWith ( ".css" ) || pathname . endsWith ( ".js" ) ? null : fetch ( source . url , source . fetchOpts ) ;
188
+ return pathname . endsWith ( ".css" ) || pathname . endsWith ( ".js" ) ? null : doFetch ( source . url , source . fetchOpts ) ;
180
189
} ) ) ;
181
190
182
191
for ( const [ index , res ] of Object . entries ( sourceResponses ) ) {
@@ -193,7 +202,7 @@ export default async function fetchCss(sources) { // eslint-disable-line import/
193
202
194
203
const fetchResponses = await Promise . all ( sources . map ( source => {
195
204
if ( ! source . url ) return null ;
196
- return Promise . all ( source . urls . map ( url => fetch ( url ) . then ( res => res . text ( ) ) ) ) ;
205
+ return Promise . all ( source . urls . map ( url => doFetch ( url ) . then ( res => res . text ( ) ) ) ) ;
197
206
} ) ) ;
198
207
199
208
for ( const [ index , responses ] of Object . entries ( fetchResponses ) ) {
0 commit comments