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

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
Ad

More from Harry Potter (20)

PDF
How to build a rest api.pptx
PPTX
Business analytics and data mining
PPTX
Big picture of data mining
PPTX
Data mining and knowledge discovery
PPTX
Cache recap
PPTX
Directory based cache coherence
PPTX
How analysis services caching works
PPTX
Optimizing shared caches in chip multiprocessors
PPTX
Hardware managed cache
PPTX
Smm & caching
PPTX
Data structures and algorithms
PPT
Abstract data types
PPTX
Abstraction file
PPTX
Object model
PPTX
Concurrency with java
PPTX
Encapsulation anonymous class
PPT
Abstract class
PPTX
Object oriented analysis
PPTX
Api crash
PPTX
Rest api to integrate with your site
How to build a rest api.pptx
Business analytics and data mining
Big picture of data mining
Data mining and knowledge discovery
Cache recap
Directory based cache coherence
How analysis services caching works
Optimizing shared caches in chip multiprocessors
Hardware managed cache
Smm & caching
Data structures and algorithms
Abstract data types
Abstraction file
Object model
Concurrency with java
Encapsulation anonymous class
Abstract class
Object oriented analysis
Api crash
Rest api to integrate with your site

Recently uploaded (20)

PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPT
Teaching material agriculture food technology
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
cuic standard and advanced reporting.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Empathic Computing: Creating Shared Understanding
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Teaching material agriculture food technology
The AUB Centre for AI in Media Proposal.docx
sap open course for s4hana steps from ECC to s4
Assigned Numbers - 2025 - Bluetooth® Document
Reach Out and Touch Someone: Haptics and Empathic Computing
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation_ Review paper, used for researhc scholars
cuic standard and advanced reporting.pdf
Review of recent advances in non-invasive hemoglobin estimation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Unlocking AI with Model Context Protocol (MCP)
Empathic Computing: Creating Shared Understanding
MIND Revenue Release Quarter 2 2025 Press Release
Digital-Transformation-Roadmap-for-Companies.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Electronic commerce courselecture one. Pdf
Spectral efficient network and resource selection model in 5G networks
gpt5_lecture_notes_comprehensive_20250812015547.pdf

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