code: public static StackTrace from(Throwable exception) {
      checkNotNull(exception);
  
      StackTrace cause = null;
      Throwable realCause = exception.getCause();
      if (realCause != null && realCause != exception) {
        cause = from(realCause);
      }
  
      Deque<Element> elements = new ArrayDeque<>();
      for (StackTraceElement element : exception.getStackTrace()) {
        elements.add(Element.from(element));
      }
  
      String className = exception.getClass().getCanonicalName();
      String message = exception.getMessage();
      return new StackTrace(className, message, elements, cause);
    }
docs: Convert a {@link Throwable} to its equivalent {@link StackTrace}.