SlideShare a Scribd company logo
1
An Exception is…
An unusual, often unpredictable event,
detectable by software or hardware, that
requires special processing
An exception handler is a section of program
code
that is executed when a particular exception
occurs.
2
Why have exception handlers?
 With no exception handler for an
exception, your program ends at the
point of the exception (with no user
understandable data from the O/S)
 With an exception handler, you can
handle the unusual condition in an
understandable way
3
Try/Catch/Throw
 Try: The block of code monitored for
exceptions
 Catch: The block of code following
the try block handles an exception
type
 Throw: When an exception is
detected, you throw an exception
type
4
The try-catch Statement
try
Block (exception can be thrown within this block
or any called functions)
catch (FormalParameter1)
Block
catch (FormalParameter2)
TryCatchStatement
How one part of the program catches and processes
the exception that another part of the program throws.
FormalParameter
DataType VariableName
…
5
Execution of try-catch
No
statements throw
an exception
Statement
following entire try-catch
statement
A
statement throws
an exception
Exception
Handler
Statements to deal with exception are executed
Control moves
directly to exception
handler
6
O/S (Unix) or you can throw
exceptions
 O/S thrown examples
 No storage available for new
request, divide by zero
 User thrown exceptions
 Using the throw statement

More Related Content

PPTX
Java Exceptions and Exception Handling
PPTX
Exception handling in java
PPT
Chapter13 exception handling
PPTX
Exception handling in java
PPTX
Exceptions
ODP
Exception Handling In Java 15734
PPTX
Exception handling in Java
PPTX
Exception Handling in Java
Java Exceptions and Exception Handling
Exception handling in java
Chapter13 exception handling
Exception handling in java
Exceptions
Exception Handling In Java 15734
Exception handling in Java
Exception Handling in Java

What's hot (13)

PPT
Exception Handling Java
ODP
Exception Handling In Java
PPTX
Z blue exception
PPT
Week7 exception handling
ODP
PPT
Vc++ 4(exception handling)
PDF
Exception handling
PPT
12 exception handling
PDF
Introduction to Exception
PPTX
What is Exception Handling?
PPTX
Exception handling
PPTX
Introduction to java exceptions
PDF
Design byexceptions
Exception Handling Java
Exception Handling In Java
Z blue exception
Week7 exception handling
Vc++ 4(exception handling)
Exception handling
12 exception handling
Introduction to Exception
What is Exception Handling?
Exception handling
Introduction to java exceptions
Design byexceptions
Ad

Viewers also liked (20)

PPTX
Hardware managed cache
PPT
Data preperation
PPTX
Optimizing shared caches in chip multiprocessors
PPT
Data mining maximumlikelihood
PPTX
Big picture of data mining
PPTX
Data and assessment
PPT
Exception
PPT
Data preprocessing
PPTX
How analysis services caching works
PPT
Object oriented programming using c++
PPTX
Object oriented analysis
PPT
Abstract class
PPTX
Drugs and sports
PPTX
Directory based cache coherence
PPT
Data abstraction the walls
PPT
Data abstraction and object orientation
PPTX
Cobol, lisp, and python
PPTX
Data visualization
PPT
Google mock for dummies
PPTX
Java basics
Hardware managed cache
Data preperation
Optimizing shared caches in chip multiprocessors
Data mining maximumlikelihood
Big picture of data mining
Data and assessment
Exception
Data preprocessing
How analysis services caching works
Object oriented programming using c++
Object oriented analysis
Abstract class
Drugs and sports
Directory based cache coherence
Data abstraction the walls
Data abstraction and object orientation
Cobol, lisp, and python
Data visualization
Google mock for dummies
Java basics
Ad

Similar to Exception handling (20)

PPTX
Exception handling in java
PPTX
Exception Handling s the process of responding to unwanted or unexpected even...
PPT
Exception handling
PPTX
7.error management and exception handling
PPTX
Exception‐Handling in object oriented programming
PDF
Exception-Handling.pdf05g830mp6m@freeml.net
PPT
Exceptionhandling
PPT
Exception handling
PDF
Lesson 8 Handling Exceptions and Errors.pdf
PPTX
Java_Unit_3_Exceptions.pptx
PPTX
Exception Handling
PPTX
Module 4.pptxModule 4.pptxModuModule 4.pptxModule 4.pptxle 4.pptx
PPTX
Maheen oop
PPTX
unit 4 msbte syallbus for sem 4 2024-2025
PPT
Lecture 22 - Error Handling
PPTX
Exception handling
PPTX
Interface andexceptions
PPTX
Exception Handling in UiPath.pptx
PPT
Excetion handling Software Engineering Units
PPTX
UNIT III 2021R.pptx
Exception handling in java
Exception Handling s the process of responding to unwanted or unexpected even...
Exception handling
7.error management and exception handling
Exception‐Handling in object oriented programming
Exception-Handling.pdf05g830mp6m@freeml.net
Exceptionhandling
Exception handling
Lesson 8 Handling Exceptions and Errors.pdf
Java_Unit_3_Exceptions.pptx
Exception Handling
Module 4.pptxModule 4.pptxModuModule 4.pptxModule 4.pptxle 4.pptx
Maheen oop
unit 4 msbte syallbus for sem 4 2024-2025
Lecture 22 - Error Handling
Exception handling
Interface andexceptions
Exception Handling in UiPath.pptx
Excetion handling Software Engineering Units
UNIT III 2021R.pptx

More from Hoang Nguyen (20)

PPTX
Rest api to integrate with your site
PPTX
How to build a rest api
PPTX
Api crash
PPTX
Smm and caching
PPTX
Cache recap
PPTX
Python your new best friend
PPTX
Python language data types
PPTX
Python basics
PPTX
Programming for engineers in python
PPTX
Learning python
PPTX
Extending burp with python
PPTX
Object model
PPTX
Data structures and algorithms
PPT
Classes and data abstraction
PPTX
Abstraction file
PPT
Abstract data types
PPTX
Object oriented programming-with_java
PPTX
Inheritance
PPTX
Encapsulation getters setters_anonymousclass
PPTX
Concurrency with java
Rest api to integrate with your site
How to build a rest api
Api crash
Smm and caching
Cache recap
Python your new best friend
Python language data types
Python basics
Programming for engineers in python
Learning python
Extending burp with python
Object model
Data structures and algorithms
Classes and data abstraction
Abstraction file
Abstract data types
Object oriented programming-with_java
Inheritance
Encapsulation getters setters_anonymousclass
Concurrency with java

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
Machine Learning_overview_presentation.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Encapsulation theory and applications.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Getting Started with Data Integration: FME Form 101
Big Data Technologies - Introduction.pptx
Accuracy of neural networks in brain wave diagnosis of schizophrenia
“AI and Expert System Decision Support & Business Intelligence Systems”
Mobile App Security Testing_ A Comprehensive Guide.pdf
Approach and Philosophy of On baking technology
Unlocking AI with Model Context Protocol (MCP)
SOPHOS-XG Firewall Administrator PPT.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
The Rise and Fall of 3GPP – Time for a Sabbatical?
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Electronic commerce courselecture one. Pdf
Machine Learning_overview_presentation.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Encapsulation_ Review paper, used for researhc scholars
Encapsulation theory and applications.pdf
A Presentation on Artificial Intelligence
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Empathic Computing: Creating Shared Understanding
Getting Started with Data Integration: FME Form 101

Exception handling

  • 1. 1 An Exception is… An unusual, often unpredictable event, detectable by software or hardware, that requires special processing An exception handler is a section of program code that is executed when a particular exception occurs.
  • 2. 2 Why have exception handlers?  With no exception handler for an exception, your program ends at the point of the exception (with no user understandable data from the O/S)  With an exception handler, you can handle the unusual condition in an understandable way
  • 3. 3 Try/Catch/Throw  Try: The block of code monitored for exceptions  Catch: The block of code following the try block handles an exception type  Throw: When an exception is detected, you throw an exception type
  • 4. 4 The try-catch Statement try Block (exception can be thrown within this block or any called functions) catch (FormalParameter1) Block catch (FormalParameter2) TryCatchStatement How one part of the program catches and processes the exception that another part of the program throws. FormalParameter DataType VariableName …
  • 5. 5 Execution of try-catch No statements throw an exception Statement following entire try-catch statement A statement throws an exception Exception Handler Statements to deal with exception are executed Control moves directly to exception handler
  • 6. 6 O/S (Unix) or you can throw exceptions  O/S thrown examples  No storage available for new request, divide by zero  User thrown exceptions  Using the throw statement