Paip. Debugging technology Print Stack Uapi the Java PHP python summary.

Source: Internet
Author: User
Tags exception handling
Paip. Debugging technology Print Stack Uapi the Java PHP python summary.


Author Attilax Airon, email:1466519819@qq.com
Source: Attilax's Column
Address: Http://blog.csdn.net/attilax


---------Uapi
Print stack: Printstack god.printstack ()
Get Stack String:getstack


----------------PHP,
Debug_print_backtrace (), add the error line on the front row ...
Save stack to File: Print_r (Debug_backtrace ());




C:\phpdeskc9>d:\wamp\php\php.exe E:\DedeCMS-V5.7-UTF8-SP1-Full\uploads\del_some
_dir.php E:\OfflineExplorerPortable\Download Budejie,xiaohua
#0 C () called at [e:\dedecms-v5.7-utf8-sp1-full\uploads\del_some_dir.php:31]
#1 B () called at [e:\dedecms-v5.7-utf8-sp1-full\uploads\del_some_dir.php:27]
#2 A () called at [e:\dedecms-v5.7-utf8-sp1-full\uploads\del_some_dir.php:38]


Fatal error:call to undefined function d () in E:\DEDECMS-V5.7-UTF8-SP1-FULL\UPL
Oads\del_some_dir.php on line 35




The Debug_backtrace () function generates a backtrace. [1]
This function returns an associative array




------------Java
E.printstacktrace ()


Save stack to file, Method 1
Stacktraceelement [] Messages=ex.getstacktrace ();
int length=messages.length;
for (int i=0;i<length;i++) {
System.out.println ("ClassName:" +messages[i].getclassname ());
System.out.println ("GetFileName:" +messages[i].getfilename ());
System.out.println ("Getlinenumber:" +messages[i].getlinenumber ());
System.out.println ("Getmethodname:" +messages[i].getmethodname ());
System.out.println ("toString:" +messages[i].tostring ());
}
}

Save stack to file, Method 2
Public String gettrace (Throwable t) {
StringWriter stringwriter= new StringWriter ();
PrintWriter writer= New PrintWriter (StringWriter);
T.printstacktrace (writer);
StringBuffer buffer= Stringwriter.getbuffer ();
return buffer.tostring ();
}


------------python
info = Traceback.format_exc ()
Print Info


Reference:
Python exception handling and exception information tracking-Fun (sugar-sweetened mung bean soup)-power by supdo!. Htm

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.