James Tam Java Exception Handling Handling errors using Java’s exception handling mechanism.
exception handling in cpp
-
Upload
gourav-kottawar -
Category
Education
-
view
147 -
download
0
Transcript of exception handling in cpp
Exception handling
Chap 13Exception handling 1By:-Gourav Kottawar
Contents13.1 Exception Handling Fundamentals 13.2 The try Block, the catch Exception Handler 13.3 The throw Statements 13.4 The try/throw/catch sequence 13.5 Exception Specification 13.6 Unexpected Exception 13.7 Catch All Exception Handlers 13.8 Throwing an exception from handler 13.9 Uncaught Exception
2By:-Gourav Kottawar
3Syntax Errors, Runtime Errors, and Logic Errorsthree categories of errors: syntax errors, runtime errors, and logic errors. Syntax errors arise because the rules of the language have not been followed. They are detected by the compiler. Runtime errors occur while the program is running if the environment detects an operation that is impossible to carry out. Logic errors occur when a program doesn't perform the way it was intended to. By:-Gourav Kottawar
3
IntroductionAllows to manage run time errors Using exception handling program can invoke automatically invoke an error handling routine when an error occurs.Automates error handling code.4By:-Gourav Kottawar
13.1 Exception Handling Fundamentals Based on three try , catch and throwCode that we want to monitor for exceptions must have been executed from within try block.Functions called from try block may also throw an exception.Exception that can be thrown by the monitored code are caught by a catch statement.
5By:-Gourav Kottawar
13.1 Exception Handling Fundamentals General syntax try{//try block}catch(type1 args) {//catch block}catch(type2 args) {//catch block}catch(type3 args) {//catch block}
....catch(typeN args) {//catch block}
General form of throwthrow exception6By:-Gourav Kottawar
#include#includeint main(){cout