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
Hashfunction
PPT
Xml and webdata
PPTX
Data structures and algorithms
PPTX
La informacion andres sanchez- nidia rodriguez
PPT
Computer security
PPTX
Cobol, lisp, and python
PPT
Big data
PPTX
Python language data types
PDF
Text categorization as a graph
PPTX
Data visualization
PPT
Data preprocessing
PPT
Memory caching
PPTX
Api crash
PPTX
Python basics
PPTX
Big picture of data mining
PPTX
Cache recap
PPT
Abstract data types
PPT
PPTX
Python your new best friend
PPTX
Datamining with nb
Hashfunction
Xml and webdata
Data structures and algorithms
La informacion andres sanchez- nidia rodriguez
Computer security
Cobol, lisp, and python
Big data
Python language data types
Text categorization as a graph
Data visualization
Data preprocessing
Memory caching
Api crash
Python basics
Big picture of data mining
Cache recap
Abstract data types
Python your new best friend
Datamining with nb
Ad

Similar to Exception handling (20)

PPTX
Exception handling with python class 12.pptx
PDF
Python Programming - X. Exception Handling and Assertions
PPTX
Maheen oop
PPTX
Lecture 3.1.1 Try Throw Catch.pptx
PPTX
Exception handling.pptxnn h
PPTX
Python Exceptions Powerpoint Presentation
PPSX
Exception Handling
PPT
PPTX
Exception handling in python
PPT
Exceptions in c++
PPTX
Java SE 11 Exception Handling
PPT
33aa27cae9c84fd12762a4ecdc288df822623524-1705207147822.ppt
PPT
Exceptionhandling
PPTX
Exceptions in C++ Object Oriented Programming.pptx
PPTX
presentation-on-exception-handling-160611180456 (1).pptx
PPTX
Exceptions
PPTX
exception handling.pptx
PPTX
Chapter 5
Exception handling with python class 12.pptx
Python Programming - X. Exception Handling and Assertions
Maheen oop
Lecture 3.1.1 Try Throw Catch.pptx
Exception handling.pptxnn h
Python Exceptions Powerpoint Presentation
Exception Handling
Exception handling in python
Exceptions in c++
Java SE 11 Exception Handling
33aa27cae9c84fd12762a4ecdc288df822623524-1705207147822.ppt
Exceptionhandling
Exceptions in C++ Object Oriented Programming.pptx
presentation-on-exception-handling-160611180456 (1).pptx
Exceptions
exception handling.pptx
Chapter 5

More from Young Alista (20)

PPTX
Google appenginejava.ppt
PDF
Motivation for multithreaded architectures
PPT
Serialization/deserialization
PPTX
Business analytics and data mining
PPTX
Data mining and knowledge discovery
PPTX
Directory based cache coherence
PPTX
Hardware managed cache
PPTX
How analysis services caching works
PPTX
Object model
PPTX
Optimizing shared caches in chip multiprocessors
PPTX
Abstraction file
PPTX
Concurrency with java
PPT
Abstract class
PPTX
Inheritance
PPTX
Object oriented analysis
PPTX
Programming for engineers in python
PPTX
Learning python
PPTX
Extending burp with python
PPTX
Rest api to integrate with your site
PPT
Poo java
Google appenginejava.ppt
Motivation for multithreaded architectures
Serialization/deserialization
Business analytics and data mining
Data mining and knowledge discovery
Directory based cache coherence
Hardware managed cache
How analysis services caching works
Object model
Optimizing shared caches in chip multiprocessors
Abstraction file
Concurrency with java
Abstract class
Inheritance
Object oriented analysis
Programming for engineers in python
Learning python
Extending burp with python
Rest api to integrate with your site
Poo java

Recently uploaded (20)

PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Cloud computing and distributed systems.
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Approach and Philosophy of On baking technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
cuic standard and advanced reporting.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Encapsulation theory and applications.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
Spectral efficient network and resource selection model in 5G networks
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The AUB Centre for AI in Media Proposal.docx
Cloud computing and distributed systems.
Assigned Numbers - 2025 - Bluetooth® Document
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Unlocking AI with Model Context Protocol (MCP)
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Approach and Philosophy of On baking technology
Network Security Unit 5.pdf for BCA BBA.
cuic standard and advanced reporting.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Per capita expenditure prediction using model stacking based on satellite ima...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
A Presentation on Artificial Intelligence
Encapsulation theory and applications.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing

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