@@ -115,7 +115,6 @@ export async function defaultHandler(
115
115
) ;
116
116
return buildSuccessResponse ( result , options ?. streamCreator , etag ) ;
117
117
} catch ( e : any ) {
118
- // All image-related errors should be treated as client errors
119
118
// Extract status code from error or default to 400 Bad Request
120
119
const statusCode = e . statusCode || 400 ;
121
120
const errorMessage = e . message || "Failed to process image request" ;
@@ -339,7 +338,7 @@ async function downloadHandler(
339
338
340
339
// Main handler logic with clearer error paths
341
340
try {
342
- // EXTERNAL IMAGE HANDLING
341
+ // remote image URL => download the image from the URL
343
342
if ( url . href . toLowerCase ( ) . match ( / ^ h t t p s ? : \/ \/ / ) ) {
344
343
try {
345
344
pipeStream ( https . get ( url ) , res , false ) ;
@@ -349,15 +348,15 @@ async function downloadHandler(
349
348
return ;
350
349
}
351
350
352
- // INTERNAL IMAGE HANDLING ( S3)
351
+ // local image => download the image from the provided ImageLoader (default is S3)
353
352
try {
354
353
const response = await loader . load ( url . href ) ;
355
354
356
355
// Handle empty response body
357
356
if ( ! response . body ) {
358
357
const message = "Empty response body from the S3 request." ;
359
358
const clientError = new IgnorableError ( message , 400 ) ;
360
- error ( "Empty response from S3 " , clientError ) ;
359
+ error ( "Empty response from ImageLoader " , clientError ) ;
361
360
362
361
res . statusCode = 400 ;
363
362
res . setHeader ( "Content-Type" , "text/plain" ) ;
0 commit comments