Line Cheng Stacks stacktrace usage, code call tree view, error code location information hint, code class name Package name File name view

Source: Internet
Author: User


1. Code Call Tree View





2. Error code location information hint




function function:
    /** output the message info in Logcat, and gives the full call tree */public static void Messagewithsrctree (String info) {stacktraceelement[] in the code that outputs the information Elem = Thread.CurrentThread (). Getstacktrace ()//from the current location, get code call stack for (stacktraceelement e:elem) {String str = E.getfilename () + "" + e.getlinenumber () + "line:" + e.getclassname () + "+" +  E.getmethodname () + "()"; Gdx.app.error (info, str);//Output call location information//    <span style= "White-space:pre" ></SPAN>LOG.E (info, str);// SYSTEM.OUT.PRINTLN (info + "  " + str);}}
<pre name= "code" class= "Java" >
<span style= "White-space:pre" ></span>//when a try block error, give the current code location, error message//try{...} catch (Exception e) {tools.messagewithsrcsite ("Error executing try{}"! "); }
<span style= "White-space:pre" ></span>/** output hint info in Logcat and gives the output of the message in the code where the call is */public static void Messagewithsrcsite (String info) {stacktraceelement[] Elem = Thread.CurrentThread (). Getstacktrace ();//from the current position, Gets the code call stack stacktraceelement e = elem[3];//only gets the code location that called the function, does not get the full call Tree string str = e.getfilename () + "" + e.getlinenumber () + "line: "+ e.getclassname () +", "  + e.getmethodname () +" () "; Gdx.app.error (info, str);//Output call location information//    <span style= "White-space:pre" ></SPAN>LOG.E (info, str);// SYSTEM.OUT.PRINTLN (info + "  " + str);}






Line Cheng Stacks stacktrace usage, code call tree view, error code location information hint, code class name Package name File name view

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.