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

15
LINES

< > BotCompany Repo | #1015769 // extractAndPrintJavaParseError

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

Libraryless. Click here for Pure Java version (3290L/20K).

sS extractAndPrintJavaParseError(S src, Throwable e) {
  new StringBuilder buf;
  print_tee(buf);
  S msg = takeFirstLines(2, innerMessage(e));
  print_tee(buf, msg);
  int line = parseIntOpt(regexpFirstGroupIC("line (\\d+)", msg));
  print_tee(buf);
  if (line != 0) {
    L<S> lines = lines(src);
    for (int i = max(1, line-5); i <= min(l(lines), line+5); i++)
      print_tee(buf, (i == line ? "* " : "  ") + "LINE " + i + ": " + lines.get(i-1));
  }
  print_tee(buf);
  ret str(buf);
}

Author comment

Began life as a copy of #1015768

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015769
Snippet name: extractAndPrintJavaParseError
Eternal ID of this version: #1015769/7
Text MD5: ca7aabd81880661e8e4651ddfa7a6eea
Transpilation MD5: e64204e1f8f565048a327f23f5145850
Author: stefan
Category: javax / code analysis
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-22 07:13:05
Source code size: 505 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 350 / 429
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1031181 - printLineWithContext