Title:
CFSaveContent does not capture output up to the point where an exception is raised
| View in TrackerStatus/Resolution/Reason: To Fix//BugVerified
Reporter/Name(from Bugbase): Bradley W. / ()
Created: 01/31/2020
Components: Language
Versions: 2016,11.0,2018
Failure Type: Non Functioning
Found In Build/Fixed In Build: Final /
Priority/Frequency: Normal / Unknown
Locale/System: English / Platforms All
Vote Count: 0
Problem Description:
If I wrap cfsavecontent around a call to capture the output and that call outputs some text and then raises an exception. cfsavecontent fails to capture the next that was output prior to the exception and instead captures nothing.
Steps to Reproduce:
try {
cfsavecontent( variable="out" ) {
writeOutput( 'I like spam' )
throw( 'boom' )
}
} catch( any e ) {
// handle error
} finally {
writedump( out )
}
Actual Result:
Variable OUT is undefined
Expected Result:
The out variable should exist and contain the contents of the buffer that was output prior to the exception.
Any Workarounds:
I found this hacky workaround where I prevent the error from hitting the cfsavecontent and then rethrow it later after capturing the output.
cfsavecontent( variable="out" ) {
try {
writeOutput( 'I like spam' )
throw( 'boom' )
} catch( any e ) {
thisFailure = e;
}
}
writedump( out )
// Rethrow
if( !isNull( thisFailure ) ) {
throw( thisFailure );
}
Attachments:
Comments: