Skip to content

Commit 38daaf5

Browse files
committed
fix: makes the code cleaner and more reliable since it is throwing errors and seeking them in the right area. Lessons_14 ecommerce folder - Joseph Caballero
1 parent 959e183 commit 38daaf5

File tree

1 file changed

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

1 file changed

+1
-7
lines changed

lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/EcommerceSystem.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public void addProduct(String productId, String name) {
1919

2020
public String placeOrder(String productId, int quantity) throws ProductNotFoundException {
2121
Product product = products.get(productId);
22-
2322
if (product == null) {
2423
throw new ProductNotFoundException("Product with ID " + productId + " not found");
2524
}
@@ -28,22 +27,17 @@ public String placeOrder(String productId, int quantity) throws ProductNotFoundE
2827
return orderId;
2928
}
3029

31-
public void cancelOrder(String orderId) throws OrderNotFoundException {
32-
if (orders == null) {
33-
throw new OrderNotFoundException("Product with ID " + orderId + " not found");
34-
}
30+
public void cancelOrder(String orderId) {
3531
orders.remove(orderId);
3632
}
3733

3834
public String checkOrderStatus(String orderId)
3935
throws OrderNotFoundException, ProductNotFoundException {
4036

4137
Order order = orders.get(orderId);
42-
4338
if (order == null) {
4439
throw new OrderNotFoundException("Order with ID " + orderId + " not found");
4540
}
46-
4741
return "Order ID: "
4842
+ orderId
4943
+ ", Product: "

0 commit comments

Comments
 (0)