File tree Expand file tree Collapse file tree 4 files changed +24
-4
lines changed
Expand file tree Collapse file tree 4 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @sveltejs/adapter-cloudflare ' : patch
3+ ---
4+
5+ fix: improve the error message when ` read(...) ` fails
Original file line number Diff line number Diff line change 1+ ---
2+ ' @sveltejs/adapter-netlify ' : patch
3+ ---
4+
5+ fix: improve the error message when ` read(...) ` fails from an edge function
Original file line number Diff line number Diff line change @@ -21,12 +21,17 @@ const initialized = server.init({
2121 // @ts -expect-error env contains environment variables and bindings
2222 env,
2323 read : async ( file ) => {
24+ const url = `${ origin } /${ file } ` ;
2425 const response = await /** @type {{ ASSETS: { fetch: typeof fetch } } } */ ( env ) . ASSETS . fetch (
25- ` ${ origin } / ${ file } `
26+ url
2627 ) ;
28+
2729 if ( ! response . ok ) {
28- throw new Error ( `Failed to fetch ${ file } : ${ response . status } ${ response . statusText } ` ) ;
30+ throw new Error (
31+ `read(...) failed: could not fetch ${ url } (${ response . status } ${ response . statusText } )`
32+ ) ;
2933 }
34+
3035 return response . body ;
3136 }
3237} ) ;
Original file line number Diff line number Diff line change @@ -14,10 +14,15 @@ const initialized = server.init({
1414 // @ts -ignore
1515 env : Deno . env . toObject ( ) ,
1616 read : async ( file ) => {
17- const response = await fetch ( `${ origin } /${ file } ` ) ;
17+ const url = `${ origin } /${ file } ` ;
18+ const response = await fetch ( url ) ;
19+
1820 if ( ! response . ok ) {
19- throw new Error ( `Failed to fetch ${ file } : ${ response . status } ${ response . statusText } ` ) ;
21+ throw new Error (
22+ `read(...) failed: could not fetch ${ url } (${ response . status } ${ response . statusText } )`
23+ ) ;
2024 }
25+
2126 return response . body ;
2227 }
2328} ) ;
You can’t perform that action at this time.
0 commit comments