EntityNotFoundException.java

  1. package edu.ucsb.cs156.rec.errors;

  2. /**
  3.  * This is an error class for a custom RuntimeException in Java that is used to indicate
  4.  * when an entity of a specific type with a given ID is not found.
  5.  */
  6. public class EntityNotFoundException extends RuntimeException {
  7.   /**
  8.    * Constructor for the exception
  9.    *
  10.    * @param entityType The class of the entity that was not found, e.g. User.class
  11.    * @param id the id that was being searched for
  12.    */
  13.   public EntityNotFoundException(Class<?> entityType, Object id) {
  14.     super("%s with id %s not found"
  15.       .formatted(entityType.getSimpleName(), id.toString()));
  16.   }
  17. }