SlideShare a Scribd company logo
STORED PROCEDURE
TRY CATCH & EXCEPTION
HANDLING
RAJISHMA T.
26/04/13
EXCEPTIONS
• An exception is an event,which occurs during
the execution of a program,that disrupts the
normal flow of the programs instruction.
• When an error occurs within amethod,the
method creates an object and hands it off to
the runtime system.
• Creating an exception object and handing it to
the runtime system is called throwing an
exception.
Exception classes
• The figure below shows the hierarchy of the
Exception classes.
Checked vs unchecked
• the subclasses of Error and RuntimeException are known as
unchecked exceptions.
• These exceptions are not checked by the compiler, and
hence, need not be caught or declared to be thrown in your
program.
• This is because there is not much you can do with these
except.
• All the other exception are called checked exceptions.
• They are checked by the compiler and must be caught or
declared to be thrown .
Exception handling process
Catching & handling exceptions
• 3 exception handler components
try
catch
finally
try
• The first step in constructing an exception
handler is to enclose the code that might
throw an exception within a try block.
try
{
code
}
catch and finally blocks . . .
Catch
• You can associates exception handlers with a
try block by providing one or more catch block
directly after the try block.
try { }
catch(exception type name){}
catch(exception type name){}
Each catch block is an exception handler &
handles the type of exception indicated by its
argument.
Finally block
• The finally block always execute when the try
block exits
• This ensures that the finally blockis executed
even if an unexpected exception occurs.
• Whwt the finally will do is contain some code
,whether or not an exception is thrown,that
code will execute.
Try catch eg:
public class TC
{
public static void main(String[] args)
{
int a=10;
int b=5,c=5;
int x,y;
try
{
x = a / (b-c);
}
catch(ArithmeticException e)
{
System.out.println("Divide by zero");
}
y = a / (b+c);
System.out.println("y = " + y);
}
}
Eg 2:
• public class TryExample
{
public static void main(String args[])
{
String str = "2346512aa";
int sum = 0;
for(int i = 0; i < str.length(); i++)
{
try
{
sum += Integer.parseInt(str.charAt(i)+"");
}
catch(NumberFormatException nfe)
{
System.out.print("Yikes! ");
}
finally
{
System.out.println("i= " + i);
}
}
System.out.println("Sum: " + sum);
}
}
• i= 0
i= 1
i= 2
i= 3
i= 4
i= 5
i= 6
Yikes! i= 7
Yikes! i= 8
Sum: 23
Declaring your own exceptions
• All exceptions must be a child of Throwable.
• If you want to write a checked exception you
need to extend the Exception class.
• If you want to write a runtime exception, you
need to extend the RuntimeException class.
• We can define our own Exception class as
below:
class MyException extends Exception{ }
• Eg:
public class Security extends Exception
{
public Security()
{
super("Attempted Security Breach - User
attempted to breach security");
}
}
Thank you

More Related Content

What's hot

Exception Handling
Exception HandlingException Handling
Exception Handling
backdoor
 
Exception handler
Exception handler Exception handler
Exception handler
dishni
 
exception handling
 exception handling exception handling
exception handling
Yaswanth Babu Gummadivelli
 
Exceptions in java
Exceptions in javaExceptions in java
Exceptions in java
Rajkattamuri
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
pooja kumari
 
Types of exceptions
Types of exceptionsTypes of exceptions
Types of exceptions
myrajendra
 
Chapter v(error)
Chapter v(error)Chapter v(error)
Chapter v(error)
Chhom Karath
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
Kavitha713564
 
Exceptions in java
Exceptions in javaExceptions in java
Exceptions in java
JasmeetSingh326
 
exception handling
exception handlingexception handling
exception handling
Manav Dharman
 
Exception Handling
Exception HandlingException Handling
Exception Handling
PRN USM
 
Java - Exception Handling
Java - Exception HandlingJava - Exception Handling
Java - Exception Handling
Prabhdeep Singh
 
Java unit3
Java unit3Java unit3
Java unit3
Abhishek Khune
 
Chap12
Chap12Chap12
Chap12
Terry Yoast
 
Satish training ppt
Satish training pptSatish training ppt
Satish training ppt
satish lariya
 
Exception handling in Java
Exception handling in JavaException handling in Java
Exception handling in Java
Abhishek Pachisia
 
Exception
ExceptionException
9781439035665 ppt ch11
9781439035665 ppt ch119781439035665 ppt ch11
9781439035665 ppt ch11
Terry Yoast
 
Exceptions
ExceptionsExceptions
Exceptions
Narayana Swamy
 

What's hot (19)

Exception Handling
Exception HandlingException Handling
Exception Handling
 
Exception handler
Exception handler Exception handler
Exception handler
 
exception handling
 exception handling exception handling
exception handling
 
Exceptions in java
Exceptions in javaExceptions in java
Exceptions in java
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Types of exceptions
Types of exceptionsTypes of exceptions
Types of exceptions
 
Chapter v(error)
Chapter v(error)Chapter v(error)
Chapter v(error)
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Exceptions in java
Exceptions in javaExceptions in java
Exceptions in java
 
exception handling
exception handlingexception handling
exception handling
 
Exception Handling
Exception HandlingException Handling
Exception Handling
 
Java - Exception Handling
Java - Exception HandlingJava - Exception Handling
Java - Exception Handling
 
Java unit3
Java unit3Java unit3
Java unit3
 
Chap12
Chap12Chap12
Chap12
 
Satish training ppt
Satish training pptSatish training ppt
Satish training ppt
 
Exception handling in Java
Exception handling in JavaException handling in Java
Exception handling in Java
 
Exception
ExceptionException
Exception
 
9781439035665 ppt ch11
9781439035665 ppt ch119781439035665 ppt ch11
9781439035665 ppt ch11
 
Exceptions
ExceptionsExceptions
Exceptions
 

Viewers also liked

Memorandum rescate banca española
Memorandum rescate banca españolaMemorandum rescate banca española
Memorandum rescate banca española
ManfredNolte
 
How to setup android development environment baabtra android workshop kit Upd...
How to setup android development environment baabtra android workshop kit Upd...How to setup android development environment baabtra android workshop kit Upd...
How to setup android development environment baabtra android workshop kit Upd...
baabtra.com - No. 1 supplier of quality freshers
 
Ado.net in Asp.net
Ado.net in Asp.netAdo.net in Asp.net
Stack and heap
Stack and heapStack and heap
Travel agencies and working of travel agencies
Travel agencies and working of travel agenciesTravel agencies and working of travel agencies
Travel agencies and working of travel agencies
baabtra.com - No. 1 supplier of quality freshers
 
14 september 2012 political update
14 september 2012   political update14 september 2012   political update
14 september 2012 political update
ManfredNolte
 
Server side scripting
Server side scriptingServer side scripting
System software vs application software
System software vs application softwareSystem software vs application software
System software vs application software
baabtra.com - No. 1 supplier of quality freshers
 

Viewers also liked (8)

Memorandum rescate banca española
Memorandum rescate banca españolaMemorandum rescate banca española
Memorandum rescate banca española
 
How to setup android development environment baabtra android workshop kit Upd...
How to setup android development environment baabtra android workshop kit Upd...How to setup android development environment baabtra android workshop kit Upd...
How to setup android development environment baabtra android workshop kit Upd...
 
Ado.net in Asp.net
Ado.net in Asp.netAdo.net in Asp.net
Ado.net in Asp.net
 
Stack and heap
Stack and heapStack and heap
Stack and heap
 
Travel agencies and working of travel agencies
Travel agencies and working of travel agenciesTravel agencies and working of travel agencies
Travel agencies and working of travel agencies
 
14 september 2012 political update
14 september 2012   political update14 september 2012   political update
14 september 2012 political update
 
Server side scripting
Server side scriptingServer side scripting
Server side scripting
 
System software vs application software
System software vs application softwareSystem software vs application software
System software vs application software
 

Similar to Exceptionn

Exception handling in java
Exception handling in java Exception handling in java
Exception handling in java
yugandhar vadlamudi
 
java.pptx
java.pptxjava.pptx
java.pptx
sujatha629799
 
Java Day-5
Java Day-5Java Day-5
Java Day-5
People Strategists
 
L14 exception handling
L14 exception handlingL14 exception handling
L14 exception handling
teach4uin
 
Exception
ExceptionException
Exception
Harry Potter
 
Exception
ExceptionException
Exception
Tony Nguyen
 
Exception
ExceptionException
Exception
Luis Goldster
 
Exception
ExceptionException
Exception
Young Alista
 
Exception
ExceptionException
Exception
Hoang Nguyen
 
Exception
ExceptionException
Exception
James Wong
 
Exception
ExceptionException
Exception
Fraboni Ec
 
Exception
ExceptionException
Exception
Tony Nguyen
 
Exception
ExceptionException
Exception
Fraboni Ec
 
Exception Handling Exception Handling Exception Handling
Exception Handling Exception Handling Exception HandlingException Handling Exception Handling Exception Handling
Exception Handling Exception Handling Exception Handling
AboMohammad10
 
Chap2 exception handling
Chap2 exception handlingChap2 exception handling
Chap2 exception handling
raksharao
 
Java-Unit 3- Chap2 exception handling
Java-Unit 3- Chap2 exception handlingJava-Unit 3- Chap2 exception handling
Java-Unit 3- Chap2 exception handling
raksharao
 
Pi j4.2 software-reliability
Pi j4.2 software-reliabilityPi j4.2 software-reliability
Pi j4.2 software-reliability
mcollison
 
Exception Handling In Java Presentation. 2024
Exception Handling In Java Presentation. 2024Exception Handling In Java Presentation. 2024
Exception Handling In Java Presentation. 2024
kashyapneha2809
 
Java-Exception Handling Presentation. 2024
Java-Exception Handling Presentation. 2024Java-Exception Handling Presentation. 2024
Java-Exception Handling Presentation. 2024
nehakumari0xf
 
8.Exception handling latest(MB).ppt .
8.Exception handling latest(MB).ppt      .8.Exception handling latest(MB).ppt      .
8.Exception handling latest(MB).ppt .
happycocoman
 

Similar to Exceptionn (20)

Exception handling in java
Exception handling in java Exception handling in java
Exception handling in java
 
java.pptx
java.pptxjava.pptx
java.pptx
 
Java Day-5
Java Day-5Java Day-5
Java Day-5
 
L14 exception handling
L14 exception handlingL14 exception handling
L14 exception handling
 
Exception
ExceptionException
Exception
 
Exception
ExceptionException
Exception
 
Exception
ExceptionException
Exception
 
Exception
ExceptionException
Exception
 
Exception
ExceptionException
Exception
 
Exception
ExceptionException
Exception
 
Exception
ExceptionException
Exception
 
Exception
ExceptionException
Exception
 
Exception
ExceptionException
Exception
 
Exception Handling Exception Handling Exception Handling
Exception Handling Exception Handling Exception HandlingException Handling Exception Handling Exception Handling
Exception Handling Exception Handling Exception Handling
 
Chap2 exception handling
Chap2 exception handlingChap2 exception handling
Chap2 exception handling
 
Java-Unit 3- Chap2 exception handling
Java-Unit 3- Chap2 exception handlingJava-Unit 3- Chap2 exception handling
Java-Unit 3- Chap2 exception handling
 
Pi j4.2 software-reliability
Pi j4.2 software-reliabilityPi j4.2 software-reliability
Pi j4.2 software-reliability
 
Exception Handling In Java Presentation. 2024
Exception Handling In Java Presentation. 2024Exception Handling In Java Presentation. 2024
Exception Handling In Java Presentation. 2024
 
Java-Exception Handling Presentation. 2024
Java-Exception Handling Presentation. 2024Java-Exception Handling Presentation. 2024
Java-Exception Handling Presentation. 2024
 
8.Exception handling latest(MB).ppt .
8.Exception handling latest(MB).ppt      .8.Exception handling latest(MB).ppt      .
8.Exception handling latest(MB).ppt .
 

More from baabtra.com - No. 1 supplier of quality freshers

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
baabtra.com - No. 1 supplier of quality freshers
 
Best coding practices
Best coding practicesBest coding practices
Core java - baabtra
Core java - baabtraCore java - baabtra
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php database connectivity
Php database connectivityPhp database connectivity
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Blue brain
Blue brainBlue brain
5g
5g5g
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Gd baabtra
Gd baabtraGd baabtra

More from baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Recently uploaded

RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 

Recently uploaded (20)

RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 

Exceptionn

  • 2. TRY CATCH & EXCEPTION HANDLING RAJISHMA T. 26/04/13
  • 3. EXCEPTIONS • An exception is an event,which occurs during the execution of a program,that disrupts the normal flow of the programs instruction. • When an error occurs within amethod,the method creates an object and hands it off to the runtime system. • Creating an exception object and handing it to the runtime system is called throwing an exception.
  • 4. Exception classes • The figure below shows the hierarchy of the Exception classes.
  • 5. Checked vs unchecked • the subclasses of Error and RuntimeException are known as unchecked exceptions. • These exceptions are not checked by the compiler, and hence, need not be caught or declared to be thrown in your program. • This is because there is not much you can do with these except. • All the other exception are called checked exceptions. • They are checked by the compiler and must be caught or declared to be thrown .
  • 7. Catching & handling exceptions • 3 exception handler components try catch finally
  • 8. try • The first step in constructing an exception handler is to enclose the code that might throw an exception within a try block. try { code } catch and finally blocks . . .
  • 9. Catch • You can associates exception handlers with a try block by providing one or more catch block directly after the try block. try { } catch(exception type name){} catch(exception type name){} Each catch block is an exception handler & handles the type of exception indicated by its argument.
  • 10. Finally block • The finally block always execute when the try block exits • This ensures that the finally blockis executed even if an unexpected exception occurs. • Whwt the finally will do is contain some code ,whether or not an exception is thrown,that code will execute.
  • 11. Try catch eg: public class TC { public static void main(String[] args) { int a=10; int b=5,c=5; int x,y; try { x = a / (b-c); } catch(ArithmeticException e) { System.out.println("Divide by zero"); } y = a / (b+c); System.out.println("y = " + y); } }
  • 12. Eg 2: • public class TryExample { public static void main(String args[]) { String str = "2346512aa"; int sum = 0; for(int i = 0; i < str.length(); i++) { try { sum += Integer.parseInt(str.charAt(i)+""); } catch(NumberFormatException nfe) { System.out.print("Yikes! "); } finally { System.out.println("i= " + i); } } System.out.println("Sum: " + sum); } }
  • 13. • i= 0 i= 1 i= 2 i= 3 i= 4 i= 5 i= 6 Yikes! i= 7 Yikes! i= 8 Sum: 23
  • 14. Declaring your own exceptions • All exceptions must be a child of Throwable. • If you want to write a checked exception you need to extend the Exception class. • If you want to write a runtime exception, you need to extend the RuntimeException class. • We can define our own Exception class as below: class MyException extends Exception{ }
  • 15. • Eg: public class Security extends Exception { public Security() { super("Attempted Security Breach - User attempted to breach security"); } }