public static ServiceException createAndRethrow(Throwable exn) { if (exn instanceof ServiceException) { return ((ServiceException) exn).rethrow(); } else { return new AmpException(exn); } } }
/** * Rethrows an exception to record the full stack trace, both caller * and callee. */ public ServiceException rethrow() { return rethrow(getMessage()); }
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); } } }
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; }