diff --git a/schools/javadocs/com/lambdaschool/zoos/services/ZooServiceImpl.html b/schools/javadocs/com/lambdaschool/zoos/services/ZooServiceImpl.html
index 10bef294..845a2d71 100644
--- a/schools/javadocs/com/lambdaschool/zoos/services/ZooServiceImpl.html
+++ b/schools/javadocs/com/lambdaschool/zoos/services/ZooServiceImpl.html
@@ -376,7 +376,7 @@
update
delete
@Transactional
public void delete(long id)
- throws javax.persistence.EntityNotFoundException
+ throws javax.persistence.ResourceNotFoundException
Deletes the course record, it student course combinations, and its telephone items from the database based off of the provided primary key
@@ -385,7 +385,7 @@ delete
- Parameters:
id - id The primary key (long) of the course you seek.
- Throws:
-javax.persistence.EntityNotFoundException
+javax.persistence.ResourceNotFoundException
@@ -438,7 +438,7 @@ saveZooAnimalCombo
findZooByLikeName
public java.util.ArrayList<Zoo> findZooByLikeName(java.lang.String name)
- throws javax.persistence.EntityNotFoundException
+ throws javax.persistence.ResourceNotFoundException
A list of all zoos whose name contains the given substring
A Stretch Goal
@@ -450,7 +450,7 @@ findZooByLikeName
Returns:
List of zoos whose name contains the given substring
Throws:
-javax.persistence.EntityNotFoundException
+javax.persistence.ResourceNotFoundException
diff --git a/schools/src/main/java/com/lambdaschool/schools/exceptions/CustomErrorDetails.java b/schools/src/main/java/com/lambdaschool/schools/exceptions/CustomErrorDetails.java
new file mode 100644
index 00000000..93f072ba
--- /dev/null
+++ b/schools/src/main/java/com/lambdaschool/schools/exceptions/CustomErrorDetails.java
@@ -0,0 +1,36 @@
+package com.lambdaschool.schools.exceptions;
+
+import com.lambdaschool.schools.services.HelperFunction;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.WebRequest;
+
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+@Component
+public class CustomErrorDetails extends DefaultErrorAttributes {
+
+ @Autowired
+ private HelperFunction helperFunction;
+
+ @Override
+ public Map getErrorAttributes(WebRequest webRequest, boolean includeStackTrace) {
+ Map errors = super.getErrorAttributes(webRequest, includeStackTrace);
+
+ Map newFormat = new LinkedHashMap<>();
+
+ newFormat.put("title", errors.get("error"));
+ newFormat.put("status", errors.get("status"));
+ newFormat.put("detail", errors.get("message"));
+ newFormat.put("timestamp", new Date());
+ newFormat.put("developerMessage","path " + errors.get("path"));
+
+ newFormat.put("errors", helperFunction.getValiErrors(this.getError(webRequest)));
+
+ return newFormat;
+
+ }
+}
diff --git a/schools/src/main/java/com/lambdaschool/schools/exceptions/ResourceNotFoundException.java b/schools/src/main/java/com/lambdaschool/schools/exceptions/ResourceNotFoundException.java
new file mode 100644
index 00000000..db98a193
--- /dev/null
+++ b/schools/src/main/java/com/lambdaschool/schools/exceptions/ResourceNotFoundException.java
@@ -0,0 +1,5 @@
+package com.lambdaschool.schools.exceptions;
+
+public class ResourceNotFoundException extends RuntimeException{
+ public ResourceNotFoundException(String message) {super("Found an error with School: " + message);}
+}
diff --git a/schools/src/main/java/com/lambdaschool/schools/handlers/RestExceptionHandler.java b/schools/src/main/java/com/lambdaschool/schools/handlers/RestExceptionHandler.java
new file mode 100644
index 00000000..476b81c6
--- /dev/null
+++ b/schools/src/main/java/com/lambdaschool/schools/handlers/RestExceptionHandler.java
@@ -0,0 +1,54 @@
+package com.lambdaschool.schools.handlers;
+
+import com.lambdaschool.schools.exceptions.ResourceNotFoundException;
+import com.lambdaschool.schools.models.ErrorDetail;
+import com.lambdaschool.schools.services.HelperFunction;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+import org.springframework.web.context.request.WebRequest;
+import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
+
+import java.util.Date;
+
+@RestControllerAdvice
+@Order(Ordered.HIGHEST_PRECEDENCE)
+public class RestExceptionHandler extends ResponseEntityExceptionHandler {
+
+ @Autowired
+ private HelperFunction helperFunction;
+
+ @ExceptionHandler(ResourceNotFoundException.class)
+ public ResponseEntity> handleResourceNotFoundException(ResourceNotFoundException rnfe){
+ ErrorDetail errorDetail = new ErrorDetail();
+
+ errorDetail.getTimestamp(new Date());
+ errorDetail.setTitle("Resource Not Found");
+ errorDetail.setStatus(HttpStatus.NOT_FOUND.value());
+ errorDetail.setDetail(rnfe.getMessage());
+ errorDetail.setDeveloperMessage(rnfe.getClass().getName());
+ errorDetail.setErrors(helperFunction.getValiErrors(rnfe));
+
+ return new ResponseEntity<>(errorDetail, null, HttpStatus.NOT_FOUND);
+
+ }
+
+ @Override
+ protected ResponseEntity