tryWithAttempts
Attempts to execute a block of code with retries and a delay between attempts.
Return
The result of the block if successful.
Parameters
T
The type of the result returned by the block.
attempts
The maximum number of attempts to execute the block before giving up. Default is 3.
delay
The delay in milliseconds between attempts. Default is 5000ms (5 seconds).
block
The block of code to execute.
Throws
If the block fails after the maximum number of attempts.