public static ExceptionWithContext withContext(Throwable ex, String str) {
    ExceptionWithContext ewc;

    if (ex instanceof ExceptionWithContext) {
      ewc = (ExceptionWithContext) ex;
    } else {
      ewc = new ExceptionWithContext(ex);
    }

    ewc.addContext(str);
    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 {@code non-null;} the exception to augment
@param str {@code non-null;} context to add
@return {@code non-null;} an appropriate instance
android/android_framework/dex-maker/src/main/java/com/android/dex/util/ExceptionWithContext.java