DEV Community

Cover image for Third-Party API Error Handling in ColdFusion: Retry Logic, Circuit Breakers, and Logging
Deepak Sir
Deepak Sir

Posted on • Originally published at Medium

Third-Party API Error Handling in ColdFusion: Retry Logic, Circuit Breakers, and Logging

When ColdFusion calls a third-party API with cfhttp, robust error handling rests on four things. First, inspect the response properly — cfhttp returns a result struct with statusCode, fileContent, errorDetail, and elapsedTime, and you must decide between letting throwOnError="true" raise exceptions or checking the status code yourself. Second, retry transient failures with exponential backoff — ColdFusion has no built-in retry, so you implement it with a loop and cftry/cfcatch, adding jitter to avoid thundering-herd problems. Third, add a circuit breaker — also not built in; you track consecutive failures in a shared cache and "open" the circuit to stop hammering a dead service, then half-open to test recovery. Fourth, log everything with the native cflog/writeLog to a dedicated log file. The two exception types you must catch are COM.Allaire.ColdFusion.HTTPFailure (connection failures) and coldfusion.runtime.RequestTimedOutException (timeouts). This guide builds all four layers with verified code.
Read More

Top comments (0)