Skip to content


Errors & Exception handling

Every accomplished programmer or developer has been through lot of errors and exceptions while programming. Errors are developers’ birth right. You can’t be better programmer if you don’t know how to deal with them. Every programming language has its own way of dealing with them. The focus of this article is to help you deal with errors that are bound to occur while you develop program. To begin with we’ll discuss the different types of errors that you experience and then I will tell you how to deal with them.
What are errors?
As per oxford dictionary terms, error is mistake or condition of being morally wrong. Error in your program is likely to occur because of something done on your part or sometimes due to the compiler or environment. There are different kinds of errors that are likely to occur in your program but they are usually categorized in three types as:
•   Syntax errors
•   Runtime errors
•   Logical errors

So your job is to find out which type of error you have in your program. Then follow the necessary steps to remove it of your program. So let’s take a look at what are these error types and how to deal with them. There are many other techniques to deal with them but it depends on situations and programming languages.

Syntax errors
Syntax errors are errors that occur when programmers fail to follow the syntax rules that govern the formatting of commands. You’ll get these types of errors when you violate the syntax rules or coding standards of programming language you’re coding for. These error types are easy to fix once you understand what they are. Using the information provided by the Compiler error message and a careful observation, you can eliminate most syntax errors during script development and testing. But sometimes these error messages are not useful as they point to the wrong line or don’t provide much information about the error. Again this varies as per compiler & programming language.

Runtime error
This error is also called as execution error. This error is occurred when your software program tried to attempt some illegal action. Although these type of errors may not be able to totally prevent from occurring. This type of error can be avoided by carefully planning & designing during the development.

Logical error
This type of error cause program to perform incorrectly but not to fail. In this case you can compile and execute the program but it will not provide the output as per desired. This type of errors can be avoided with help of carefully planning the program and choosing the right algorithm.

What can we do about Exception?
There are always some exceptions for every grammatical rule. Same is the case with programming. But you can take some precaution while developing program to get over these situations. There are plenty of techniques to deal with them but this is what I came up with.

1. You can print the exception that occur is particular case, so that user can notify you when he encounters that situation. This is something that you should know already or you can think of, this will save lot of your time in future.
2. Try to record the errors occur while program execution to review later. This can be the feature within your program to log the errors occurred while execution of program.
3. Create some sort of error reporting mechanism so you can get errors to you bug database. And possibly work on it before moving onto next version. E.g. Windows has error reporting mechanism that can be used to notify the exceptions occurred while working with windows.

Conclusion
Debugging and error handling is something that consume lot of programmers time & resources. So by carefully planning and designing the program will in turn make your development effective.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.