private static void addSenderInfo(Throwable toModify, String senderId) {
    StackTraceElement[] stackTrace = toModify.getStackTrace();

    StackTraceElement element = null;
    for (int i = 0; i < stackTrace.length; i++) {
      element = stackTrace[i];
      if (!element.getClassName().startsWith(REMOTE_MEMBER_TOKEN)) {
        stackTrace[i] = new StackTraceElement(
            REMOTE_MEMBER_TOKEN + " '" + senderId + "' in " + element.getClassName(),
            element.getMethodName(), element.getFileName(), element.getLineNumber());
      }
    }

    toModify.setStackTrace(stackTrace);
    Throwable cause = toModify.getCause();

    if (cause != null) {
      addSenderInfo(cause, senderId);
    }
  }
Adds the sender information to the stack trace elements of the given exception. Also traverses
recursively over the 'cause' for adding this sender information.

@param toModify Throwable instance to modify the stack trace elements
@param senderId id of the sender member
geode-core/src/main/java/org/apache/geode/distributed/internal/ReplyException.java