Before you attempt to retry anything, ask yourself this crucial question:
Will the same action yield a different result if I try it again?
Retry for Transient Errors:
Timeout: YES (the network may recover)
Element not found: YES (the page might load)
Connection timeout: YES (the server might respond)
Do Not Retry for Permanent Errors:
Invalid credentials: NO (the credentials remain incorrect)
Customer doesn’t exist: NO (the customer will not reappear upon retry)
Validation failure: NO (the data is still invalid)
Implementation:
Try
DoSomething()
Catch ex As Exception
If IsTransientError(ex) Then
' Retry (the error is likely to disappear)
Retry()
Else
' Fail immediately (the error will not change)
Throw
End If
End Try
This approach is essential! This one question effectively eliminates 90% of problematic retry logic in automation.