Libraryless. Click here for Pure Java version (2126L/14K).
svoid retry(int attempts, Runnable r) { Throwable lastException = null; while ping (attempts-- > 0) { try { callF(r); ret; } catch print e { lastException = e; } print("Attempts remaining: " + attempts); } if (lastException != null) throw rethrow(lastException); }
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1026066 |
Snippet name: | retry - run Runnable multiple times if it throws an exception |
Eternal ID of this version: | #1026066/4 |
Text MD5: | 43eb916f1d4a64d2bcf446133fc4ab73 |
Transpilation MD5: | 473bb35419de784c46ef4f7ce19467d1 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-11-18 21:38:02 |
Source code size: | 323 bytes / 14 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 171 / 277 |
Version history: | 3 change(s) |
Referenced in: | [show references] |