如何在应用程序中找到错误 [英] How to find Error in the application

查看:82
本文介绍了如何在应用程序中找到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在应用程序中找到错误

How to find Error in the application

推荐答案

嗯...首先检查编译错误:这些通常是语法或拼写问题,可以很快解决,但是这会阻止你运行你的代码。



然后,检查编译器警告:这些通常是愚蠢的,当你运行应用程序时可能会咬你,但不会阻止你这样做。但是,你应该仔细观察它们,并尝试摆脱它们 - 我只是因为编译器确实知道它在说什么而运行将警告视为错误,并且警告通常意味着我忘了某些东西而且很可能重要。



然后当你运行你的应用程序时,你可能会遇到两类问题:



例外:应用程序发现严重错误,无法正常继续。您需要使用调试器详细查看异常并找出导致它的确切原因 - 这可能与错误变得明显的点相距一段距离。



逻辑问题:应用程序会执行您不想要的操作,或者执行您不想做的操作。



两者通过仔细使用调试器来准确解决代码中发生的事情,我们几乎无法解决这些问题:我们无法运行您的代码,因此我们无法告诉您该怎么做。使用调试器,查看代码的运行方式以及变量的作用。
Well...first check for compilation errors: these are usually syntax or spelling problems and can be solved pretty quickly, but which will prevent you from running your code.

Then, check for compiler warnings: these are usually something silly that is likely to bite you when you run the application, but won't stop you doing so. However, you should look very closely at them, and try to get rid of them - I run with "treat warnings as errors" simply because the compiler does know what it is talking about, and a warning generally means I forgot something and it's likely to be important.

Then when you run your application there are two types of problems you might get:

Exceptions: the application finds a critical error and cannot continue properly. You need to look at the exception in some detail using the debugger and work out exactly what caused it - and that may be some distance from the point at which the error became obvious to the application.

Logic problems: The application does something you didn't intend it to, or doesn't do something you did mean it to.

Both of these are pretty much only fixable by careful use of the debugger to work out exactly what is going on in your code: we can't run your code, so we can't tell you what to do. Use the debugger, and look at how your code runs, and what your variables are doing.


这篇关于如何在应用程序中找到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆