Libraryless. Click here for Pure Java version (2126L/14K).
1 | svoid retry(int attempts, Runnable r) { |
2 | Throwable lastException = null; |
3 | while ping (attempts-- > 0) { |
4 | try { |
5 | callF(r); |
6 | ret; |
7 | } catch print e { |
8 | lastException = e; |
9 | } |
10 | print("Attempts remaining: " + attempts); |
11 | } |
12 | if (lastException != null) |
13 | throw rethrow(lastException); |
14 | } |
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: | 172 / 279 |
Version history: | 3 change(s) |
Referenced in: | [show references] |