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

5
LINES

< > BotCompany Repo | #1000659 - fail functions (improved)

JavaX fragment (include)

static RuntimeException fail() { throw new RuntimeException("fail"); }
static RuntimeException fail(Throwable e) { throw asRuntimeException(e); }
static RuntimeException fail(Object msg) { throw new RuntimeException(String.valueOf(msg)); }
static RuntimeException fail(S msg) { throw new RuntimeException(msg == null ? "" : msg); }
static RuntimeException fail(S msg, Throwable innerException) { throw new RuntimeException(msg, innerException); }

Author comment

This is smartly declared so you can use either version:

  fail();
  throw fail();

(Actually JavaX, as of #752, now rewrites "fail()" to "throw fail()".)


// disabled for now to shorten some programs 
/*static RuntimeException fail(S msg, O... args) {
  throw new RuntimeException(format(msg, args));
}*/

download  show line numbers  debug dex   

Travelled to 11 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1000659
Snippet name: fail functions (improved)
Eternal ID of this version: #1000659/6
Text MD5: 876ce995c229c429fc4b9de4361758ea
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-09-19 16:18:09
Source code size: 452 bytes / 5 lines
Pitched / IR pitched: No / No
Views / Downloads: 435 / 9724
Version history: 5 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1000659 & http://1000659.tinybrain.de