// Setup some general error-checking functions (closures work as well). Each of // these function accepts the Error instance in question and must return a boolean // indicating that the error is transient (true) or non-retriable (false). function isMySqlLockTimeoutError( required any error ) { // Read more: https://dev.mysql.com/doc/refman/5.7/en/error-messages-server.html#error_er_lock_deadlock return( ( error.type == "Database" ) && ( error.errorCode == "40001" ) ); } function isSqlServerLockTimeoutError( required any error ) { // Read more: https://technet.microsoft.com/en-us/library/cc645860(v=sql.105).aspx return( ( error.type == "Database" ) && ( error.errorCode == "1222" ) ); } function isAlwaysTransientError( required any error ) { return( true ); } function isNeverTransientError( required any error ) { return( false ); } // ------------------------------------------------------------------------------- // // ------------------------------------------------------------------------------- // // Create our retry proxy using the given transient error test. proxy = new RetryProxy( new TestTarget(), isAlwaysTransientError ); try { writeDump( proxy.works() ); writeDump( proxy.breaks() ); } catch ( any error ) { // This should be the "breaks()" method error. writeDump( error ); }