* @return The same exception, for convenience.
*/
@SuppressWarnings("unchecked")
public static <T> T addExceptionContext(Throwable exception, int level) {
if (exception instanceof IHasExceptionContext) {
IHasExceptionContext hasContext = (IHasExceptionContext) exception;
ExceptionContext context = generateExceptionContext(exception, level);
hasContext.setContext(context);
}
return (T) exception;
}