06-06-2013, 04:22 PM
Managing Error and Exceptions
Managing Error.pptx (Size: 64.64 KB / Downloads: 18)
Introductions
It is common to make mistakes while writing programs
A mistake might leads to an error causing the program to return unexpected results
Error are mistakes that can make the program wrong
An Error can produce incorrect output or may terminate the execution of program
Sometimes it may leads to system crash
What is Debugging?
It is a process to identifying and fixing errors in software program so as to ensure that it behaves like in the intended manner
Such error commonly refer as bug
The use of debugger ensured a systematic approach to problem or error resolution
VS comes with inbuilt debugger that helps programmer to fix and locate errors
.NET framework also provides command line debugging tool called cordbg
Compile-Time Errors
A syntax error will be detected by the compiler at the time of compilation
When it occur, it is not going to generate executable, so it is necessary to fix all error before we compile successfully
Run-Time Errors
Sometime, program compile successfully , and generate .exe, but may not run properly
Such program may produce wrong result
Divide by zero
Accessing elements of array that are out of bound
Converting invalid string to number
Exceptions
It is a condition that is caused by a run time error
When C# compiler encounters an error such as divide by zero, it creates exception object and throws it , to inform us that an error has occurred
If exception object is not caught it and handle properly, then compiler will display error message and may terminate program
The purpose of exception handling mechanism to provide a means to detect and report ‘Exceptional Circumstances’, so that appropriate action will be taken