Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

23
LINES

< > BotCompany Repo | #1034832 // TimeoutException using getCause() - doesn't work because they are from different threads. I guess!?

JavaX fragment (include)

1  
srecord noeq TimeoutException(double timeoutSeconds,
2  
  O function,
3  
  Thread thread) extends RuntimeException {
4  
  @Override
5  
  public S getMessage() {
6  
    ret "Timeout after " + iceil(timeoutSeconds) + "s by " + shorten_str(function);
7  
  }
8  
  
9  
  StackTraceElement[] innerStackTrace() {
10  
    ret thread.getStackTrace();
11  
  }
12  
  
13  
  public cached Cause getCause() {
14  
    ret new Cause;
15  
  }
16  
  
17  
  class Cause > Throwable {
18  
    *() {
19  
      super("Still calculating", null, false, true);
20  
      setStackTrace(innerStackTrace());
21  
    }
22  
  }
23  
}

Author comment

Began life as a copy of #1034249

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034832
Snippet name: TimeoutException using getCause() - doesn't work because they are from different threads. I guess!?
Eternal ID of this version: #1034832/2
Text MD5: b9e6a24284cd4061076b405d88a057df
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-11 03:15:31
Source code size: 546 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 133 / 144
Version history: 1 change(s)
Referenced in: [show references]