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

32
LINES

< > BotCompany Repo | #1021802 // ErrorCounter

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (1811L) is out of date.

sclass ErrorCounter {
  new LPair<O, Throwable> errors;
  int total;

  void run(O info, Runnable r) {
    try {
      r.run();
    } catch print e {
      errors.add(pair(info, e));
    }
    ++total;
  }
  
  void print() {
    _print(toString_short() +
      (nempty(errors) ? "" : ". Fails: " + pairsA(errors)));
  }
  
  S toString_short() {
    ret empty(errors)
      ? "No errors (tests: " + total + ")"
      : n2(errors, "error") + " in " + n2(total, "test") + ". Fails: " + pairsA(errors);
  }
  
  void add(ErrorCounter ec) {
    if (ec == null) ret;
    total += ec.total;
    addAll(errors, ec.errors);
  }
  
  bool allCorrect() { ret empty(errors); }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021802
Snippet name: ErrorCounter
Eternal ID of this version: #1021802/9
Text MD5: 525533adda36cc11a3830223512ab323
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-29 18:03:44
Source code size: 699 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 284 / 756
Version history: 8 change(s)
Referenced in: [show references]