Handling Exceptions in E-Commerce Platforms
This program demonstrates handling exceptions in e-commerce platforms.
Problem Statement
Write a Java program that simulates order processing failure and handles exceptions.
Source Code
| 1 | public class EcommerceExceptionExample { |
| 2 | public static void main(String[] args) { |
| 3 | System.out.println("Eduinq E-Commerce Exception Example"); |
| 4 | try { |
| 5 | processOrder("outOfStock"); |
| 6 | } catch(Exception e) { |
| 7 | System.out.println("Eduinq Exception: Order Error - "+e.getMessage()); |
| 8 | } |
| 9 | } |
| 10 | static void processOrder(String status) throws Exception { |
| 11 | if("outOfStock".equals(status)) throw new Exception("Item Not Available"); |
| 12 | System.out.println("Eduinq Order Processed Successfully"); |
| 13 | } |
| 14 | } |
Program Output
Eduinq E-Commerce Exception Example Eduinq Exception: Order Error - Item Not Available
Explanation
E-commerce platforms must handle out-of-stock or invalid orders. - Exception handling ensures reliable order processing. - Provides meaningful feedback for debugging. - In enterprise systems, e-commerce exception handling ensures customer satisfaction. Conclusion: Shows handling exceptions in e-commerce platforms.