/** * Rethrows an exception to record the full stack trace, both caller * and callee. */ @Override public ServiceExceptionExecution rethrow(String msg) { return new ServiceExceptionExecution(msg, this); }
public static RuntimeException wrap(Throwable exn) { if (exn instanceof ServiceException) { return ((ServiceException) exn).rethrow(); } else if (exn instanceof RuntimeException) { try { Constructor<?> ctor = exn.getClass().getConstructor(String.class,Throwable.class); return (RuntimeException) ctor.newInstance(exn.getMessage(), exn); } catch (Exception e) { return new ServiceExceptionExecution(exn); } } else { return new ServiceExceptionExecution(exn); } } }
/** * Fails the Result with an exception. The exception will be passed to * the calling client. * * @param exn the exception */ @Override default void fail(Throwable exn) { try { handle(null, exn); } catch (Exception e) { throw new ServiceExceptionExecution(e); } }
public static ServiceException createAndRethrow(String msg, Throwable exn) { ServiceException exn1; if (exn instanceof ServiceException) { exn1 = ((ServiceException) exn).rethrow(msg); } else { exn1 = new ServiceExceptionExecution(msg, exn); } exn1.fillInStackTrace(); return exn1; }
public static ServiceException createAndRethrow(Throwable exn) { ServiceException exn1; if (exn instanceof ServiceException) { exn1 = ((ServiceException) exn).rethrow(); } else { exn1 = new ServiceExceptionExecution(exn); } exn1.fillInStackTrace(); return exn1; }