Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1.     /**
  2.      * Get a Frame from a StackTraceElement
  3.      * @param stackTraceElement the StackTraceElement (a.k.a.: stack frame)
  4.      * @return the Frame representing the StackTraceElement
  5.      * @throws ArgumentNullException if stackTraceElement is null
  6.      */
  7.     public static Frame fromStackTraceElement(StackTraceElement stackTraceElement) throws ArgumentNullException {
  8.         String filename = stackTraceElement.getFileName(); //THIS RETURNS NULL FOR SOME FRAME(S) OF THE STACKTRACE ABOVE
  9.         Integer lineNumber = stackTraceElement.getLineNumber();
  10.         String method = stackTraceElement.getMethodName();
  11.         String className = stackTraceElement.getClassName();
  12.  
  13.         //Since filename is null Frame's constructor will throw the ArgumentNullException
  14.         return new Frame(filename, lineNumber, null, method, null, className, null, null, null);
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement