How to filter program errors

Source: Internet
Author: User
How to filter errors in programs? During a development, the supervisor asked me to write an upload code. After I finished writing, the supervisor said that I did not perform filtering error processing. In writing a program, which situations should I filter errors? ------ Solution -------------------- be considerate and prompt troubleshooting for possible situations. ------ Solution ------------------ for example, the simplest one, the parameters are not passed completely. ------ How does the solution filter errors in the program?
During a development, the supervisor asked me to write an upload code.
After I finished writing, the supervisor said that I did not perform filtering error processing.
In writing a program, which situations should I filter errors?

------ Solution --------------------
Be considerate and prompt troubleshooting for possible situations.
------ Solution --------------------
For example, the simplest parameter is not completely transmitted.
------ Solution --------------------
Most of the code you see in books or on the Internet is the principle code.
It assumes that the involved environment and parameters are correct and reasonable. Therefore, the troubleshooting mechanism is not added to improve the readability of the code.

According to the software engineering rules, the actual running code must undergo various tests, and some errors caused by external factors will be exposed during the test.

It is unlikely that you will know in advance where problems may occur. even if you have years of development experience, you will also miss some minor problems.

The manual provides the main troubleshooting code for your project.
------ Solution --------------------
Just do not assume that the parameters submitted by the user are valid. check the parameters submitted by the user with this mentality.
------ Solution --------------------
Never trust user data, even if he/she is your mother

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.