/** * Augments the given exception with the given context, and return the * result. The result is either the given exception if it was an * {@link ExceptionWithContext}, or a newly-constructed exception if it * was not. * * @param ex non-null; the exception to augment * @param str non-null; context to add * @return non-null; an appropriate instance */ public static ExceptionWithContext withContext(Throwable ex, String str, Object... formatArgs) { ExceptionWithContext ewc; if (ex instanceof ExceptionWithContext) { ewc = (ExceptionWithContext) ex; } else { ewc = new ExceptionWithContext(ex); } ewc.addContext(String.format(str, formatArgs)); return ewc; }
/** * Augments the given exception with the given context, and return the * result. The result is either the given exception if it was an * {@link ExceptionWithContext}, or a newly-constructed exception if it * was not. * * @param ex non-null; the exception to augment * @param str non-null; context to add * @return non-null; an appropriate instance */ public static ExceptionWithContext withContext(Throwable ex, String str, Object... formatArgs) { ExceptionWithContext ewc; if (ex instanceof ExceptionWithContext) { ewc = (ExceptionWithContext) ex; } else { ewc = new ExceptionWithContext(ex); } ewc.addContext(String.format(str, formatArgs)); return ewc; }
/** * Augments the given exception with the given context, and return the * result. The result is either the given exception if it was an * {@link ExceptionWithContext}, or a newly-constructed exception if it * was not. * * @param ex non-null; the exception to augment * @param str non-null; context to add * @return non-null; an appropriate instance */ public static ExceptionWithContext withContext(Throwable ex, String str, Object... formatArgs) { ExceptionWithContext ewc; if (ex instanceof ExceptionWithContext) { ewc = (ExceptionWithContext) ex; } else { ewc = new ExceptionWithContext(ex); } ewc.addContext(String.format(str, formatArgs)); return ewc; }