June 2014
Beginner to intermediate
304 pages
7h 25m
English
We must show a nice error message that says that no products were found with the given product ID. Let's do that with the help of @ExceptionHandler:
ProductNotFoundException under the com.packt.webstore.exception package in the source folder src/main/java. Now, add the following code to it:package com.packt.webstore.exception;
public class ProductNotFoundException extends RuntimeException{
private static final long serialVersionUID =-694354952032299587L;
private String productId;
public ProductNotFoundException(String productId) {
this.productId = productId;
}
public String getProductId() {
return productId;
}
}InMemoryProductRepository class and modify the getProductById ...