AdobeStock_455007340

Correctly Using Try/Catch Handling

Home » Correctly Using Try/Catch Handling

and should be used to trap errors so as to be able to programmatically manage post error handling. To effectively use this feature, error handling should occur at at least two levels – at a page wide level (to catch all errors within a page) and at a feature or tag specific level (to catch errors thrown by specific tags). To facilitate this type of processing tags may be nested. And if a nested blocks catches an error that should be handled by an outer block, the tag may be used to “rethrow” the exception that caused the error. (Applies to: ColdFusion 4 (or later))

One response to “Correctly Using Try/Catch Handling”

  1. Angel Gonzalez Avatar
    Angel Gonzalez

    Why can’t I get something this simple to work…
    <cfoutput query="qryWithData">
    <cftry>
    <cfquery name="addrecords" datasource="MyDSN">
    Insert into tblVerity (listing_number, address, type, listing_price, beds, baths, districtAreaSchool)
    VALUES (#qryWithData.listing_number#, ‘#qryWithData.address#’, ‘#qryWithData.type#’, #qryWithData.listing_price#, #qryWithData.beds#, #qryWithData.baths#, ‘#qryWithData.districtAreaSchool#’)
    </cfquery>
    <cfcatch>
    <p>#error.diagnostics#</p>
    </cfcatch>
    </cftry>
    </cfoutput>

Leave a Reply