Skip to content

Commit 1b83bac

Browse files
committed
Record the originally requested image URL when logging errors Fixes #9
1 parent 4b4acb3 commit 1b83bac

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

adaptiveImages.cfc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,20 @@ component{
7777
return sendImage( cachedFilePath, mimeType );
7878
}
7979
catch( any exception ){
80+
if( config.logErrors OR config.writeLogs ){
81+
var errorLogText = "AI Error";
82+
if( arguments.KeyExists( "originalUrl" ) )
83+
errorLogText &= " serving #arguments.originalUrl#";
84+
errorLogText &= ": ";
85+
}
8086
if( !DirectoryExists( cacheFolderPath ) OR !FileExists( cachedFilePath ) ){
8187
if( config.logErrors OR config.writeLogs )
82-
WriteLog( file: config.logFilename, text: "AI: Error Occured : cached image should exist according to FO cache but is missing. Clearing FO cache." );
88+
WriteLog( file: config.logFilename, text: errorLogText & "cached image should exist according to FO cache but is missing. Clearing FO cache." );
8389
clearFileOperationsCache();
8490
}
8591
else {
8692
if( config.logErrors OR config.writeLogs )
87-
WriteLog( file: config.logFilename, text: "AI: Error Occured : #exception.message#" );
93+
WriteLog( file: config.logFilename, text: errorLogText & exception.message );
8894
cfheader( statuscode: "503", statustext: "Temporary problem" );
8995
abort;
9096
}

0 commit comments

Comments
 (0)