Professional Documents
Culture Documents
Exception Handling: "Understanding, Using, and Handling Runtime Errors "
Exception Handling: "Understanding, Using, and Handling Runtime Errors "
Nangarhar University
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 1 / 25
Agenda
1 Understanding Exception
2 Exceptions in Java
Introduction
Different Scenarios
Catching Exceptions; Syntax, and Example
3 Exceptions in PHP
Exception without try catch
Exception with try and catch
4 Exceptions in Python
Exception without try catch
Exception with try catch
5 Questions and Discussion
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 2 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 3 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 3 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 3 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 3 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 3 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 3 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 3 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 3 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 3 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 3 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 3 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 4 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 4 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 4 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 4 / 25
Understanding Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 4 / 25
Exceptions in Java Introduction
Agenda
1 Understanding Exception
2 Exceptions in Java
Introduction
Different Scenarios
Catching Exceptions; Syntax, and Example
3 Exceptions in PHP
Exception without try catch
Exception with try and catch
4 Exceptions in Python
Exception without try catch
Exception with try catch
5 Questions and Discussion
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 5 / 25
Exceptions in Java Introduction
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 6 / 25
Exceptions in Java Introduction
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 6 / 25
Exceptions in Java Introduction
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 6 / 25
Exceptions in Java Introduction
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 6 / 25
Exceptions in Java Introduction
[1]
Figure: Hierarchy of Java Exception classes
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 6 / 25
Exceptions in Java Different Scenarios
Agenda
1 Understanding Exception
2 Exceptions in Java
Introduction
Different Scenarios
Catching Exceptions; Syntax, and Example
3 Exceptions in PHP
Exception without try catch
Exception with try and catch
4 Exceptions in Python
Exception without try catch
Exception with try catch
5 Questions and Discussion
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 7 / 25
Exceptions in Java Different Scenarios
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 8 / 25
Exceptions in Java Different Scenarios
[1]
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 8 / 25
Exceptions in Java Different Scenarios
[1]
2 NullPointerException
[1]
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 8 / 25
Exceptions in Java Different Scenarios
[1]
2 NullPointerException
[1]
3 NumberFormatException
[1]
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 8 / 25
Exceptions in Java Different Scenarios
[1]
2 NullPointerException
[1]
3 NumberFormatException
[1]
4 ArrayIndexOutOfBoundsException
[1]
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 8 / 25
Exceptions in Java Catching Exceptions; Syntax, and Example
Agenda
1 Understanding Exception
2 Exceptions in Java
Introduction
Different Scenarios
Catching Exceptions; Syntax, and Example
3 Exceptions in PHP
Exception without try catch
Exception with try and catch
4 Exceptions in Python
Exception without try catch
Exception with try catch
5 Questions and Discussion
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 9 / 25
Exceptions in Java Catching Exceptions; Syntax, and Example
Catching Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 10 / 25
Exceptions in Java Catching Exceptions; Syntax, and Example
Catching Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 10 / 25
Exceptions in Java Catching Exceptions; Syntax, and Example
Catching Exception
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 10 / 25
Exceptions in Java Catching Exceptions; Syntax, and Example
Catching Exception
Syntax [2]
try{
// protected code
} catch (ExceptionName excep){
// code that execute in case an exception occur
}
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 10 / 25
Exceptions in Java Catching Exceptions; Syntax, and Example
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 11 / 25
Exceptions in Java Catching Exceptions; Syntax, and Example
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 12 / 25
Exceptions in Java Catching Exceptions; Syntax, and Example
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 12 / 25
Exceptions in Java Catching Exceptions; Syntax, and Example
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 12 / 25
Exceptions in Java Catching Exceptions; Syntax, and Example
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 12 / 25
Exceptions in Java Catching Exceptions; Syntax, and Example
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 13 / 25
Exceptions in PHP Exception without try catch
Agenda
1 Understanding Exception
2 Exceptions in Java
Introduction
Different Scenarios
Catching Exceptions; Syntax, and Example
3 Exceptions in PHP
Exception without try catch
Exception with try and catch
4 Exceptions in Python
Exception without try catch
Exception with try catch
5 Questions and Discussion
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 14 / 25
Exceptions in PHP Exception without try catch
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 15 / 25
Exceptions in PHP Exception without try catch
Output:
[3]
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 15 / 25
Exceptions in PHP Exception with try and catch
Agenda
1 Understanding Exception
2 Exceptions in Java
Introduction
Different Scenarios
Catching Exceptions; Syntax, and Example
3 Exceptions in PHP
Exception without try catch
Exception with try and catch
4 Exceptions in Python
Exception without try catch
Exception with try catch
5 Questions and Discussion
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 16 / 25
Exceptions in PHP Exception with try and catch
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 17 / 25
Exceptions in PHP Exception with try and catch
Output:
[3]
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 17 / 25
Exceptions in Python Exception without try catch
Agenda
1 Understanding Exception
2 Exceptions in Java
Introduction
Different Scenarios
Catching Exceptions; Syntax, and Example
3 Exceptions in PHP
Exception without try catch
Exception with try and catch
4 Exceptions in Python
Exception without try catch
Exception with try catch
5 Questions and Discussion
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 18 / 25
Exceptions in Python Exception without try catch
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 19 / 25
Exceptions in Python Exception with try catch
Agenda
1 Understanding Exception
2 Exceptions in Java
Introduction
Different Scenarios
Catching Exceptions; Syntax, and Example
3 Exceptions in PHP
Exception without try catch
Exception with try and catch
4 Exceptions in Python
Exception without try catch
Exception with try catch
5 Questions and Discussion
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 20 / 25
Exceptions in Python Exception with try catch
[1]
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 21 / 25
Questions and Discussion
1
https://fensafitters.files.wordpress.com/2013/07/3d095.jpg
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 22 / 25
Questions and Discussion
References
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 23 / 25
Questions and Discussion
References
Java Point
Exception Handling in Java
http://www.javatpoint.com/exception-handling-in-java ,
date visited Feb 18, 2017.
Tutorials Point
Java - Exceptions
https://www.tutorialspoint.com/java/java_exceptions.htm ,
date visited Feb 18, 2017.
W3 Schools
PHP Exception Handling
https://www.w3schools.com/php/php_exception.asp , date
visited Feb 18, 2017.
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 24 / 25
Questions and Discussion
References
Tutorials Point
Python Exceptions Handling
https:
//www.tutorialspoint.com/python/python_exceptions.htm ,
date visited Feb 18, 2017.
Amin Gul zakhi (Nangarhar University) Exception Handling March 27, 2019 25 / 25