Skip to content

Commit dea4134

Browse files
author
AmiyahJo
committed
feat: adds try-catch blocks with exceptions
chore: comments for reference
1 parent 669db42 commit dea4134

File tree

1 file changed

+11
-1
lines changed
  • lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14

1 file changed

+11
-1
lines changed

lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
public class Lesson14 {
44

55
public static void main(String[] args) {
6-
System.out.println("Hello World");
6+
// System.out.println("Hello World");
7+
try {
8+
ecommerceSystem.placeOrder("1", 1);
9+
} catch (ProductNotFoundException e) {
10+
System.out.println("Product not found.");
11+
} catch (OrderNotFoundException e){
12+
System.out.println("Order not found.");
13+
}
714
}
815
}
16+
17+
//ProductNotFoundException <- for product does not exist
18+
//OrderNotFoundException <- for both order does not exist and order cancelled

0 commit comments

Comments
 (0)