public class TestClass { public class CheckFailure extends RuntimeException { public String msg; CheckFailure(String msg){ this.msg = msg; } } protected void check(boolean expr) throws CheckFailure{ if (!expr) throw new CheckFailure(""); } protected void check(String msg, boolean expr) throws CheckFailure{ if (!expr) throw new CheckFailure(msg); } }