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..3d77685d
--- /dev/null
+++ b/schools/src/main/java/com/lambdaschool/schools/exceptions/CustomErrorDetails.java
@@ -0,0 +1,33 @@
+package com.lambdaschool.schools.exceptions;
+
+import com.lambdaschool.schools.services.HelperFunctions;
+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.LinkedHashMap;
+import java.util.Map;
+
+@Component
+public class CustomErrorDetails extends DefaultErrorAttributes {
+
+ @Autowired
+ HelperFunctions helperFunctions;
+
+ @Override
+ public Map getErrorAttributes(WebRequest webRequest, boolean includeStackTrace) {
+ Map errorAttributes = super.getErrorAttributes(webRequest, includeStackTrace);
+
+ Map errorDetails = new LinkedHashMap<>();
+ errorDetails.put("title", errorAttributes.get("error"));
+ errorDetails.put("status", errorAttributes.get("status"));
+ errorDetails.put("detail", "Found an issue with School: " + errorAttributes.get("message"));
+ errorDetails.put("timestamp", errorAttributes.get("timestamp"));
+ errorDetails.put("developer", "Path: " + errorAttributes.get("path"));
+ errorDetails.put("errors", helperFunctions.getConstraintViolation(this.getError(webRequest)));
+ return errorDetails;
+
+
+ }
+}
diff --git a/schools/src/main/java/com/lambdaschool/schools/exceptions/ResourceFoundException.java b/schools/src/main/java/com/lambdaschool/schools/exceptions/ResourceFoundException.java
new file mode 100644
index 00000000..e36f357c
--- /dev/null
+++ b/schools/src/main/java/com/lambdaschool/schools/exceptions/ResourceFoundException.java
@@ -0,0 +1,8 @@
+package com.lambdaschool.schools.exceptions;
+
+public class ResourceFoundException extends RuntimeException{
+
+ public ResourceFoundException(String message) {
+ super(message);
+ }
+}
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..7f3607a3
--- /dev/null
+++ b/schools/src/main/java/com/lambdaschool/schools/exceptions/ResourceNotFoundException.java
@@ -0,0 +1,8 @@
+package com.lambdaschool.schools.exceptions;
+
+public class ResourceNotFoundException extends RuntimeException{
+
+ public ResourceNotFoundException(String message) {
+ super(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..a0f1cca1
--- /dev/null
+++ b/schools/src/main/java/com/lambdaschool/schools/handlers/RestExceptionHandler.java
@@ -0,0 +1,69 @@
+package com.lambdaschool.schools.handlers;
+
+import com.lambdaschool.schools.exceptions.ResourceFoundException;
+import com.lambdaschool.schools.exceptions.ResourceNotFoundException;
+import com.lambdaschool.schools.models.ErrorDetail;
+import com.lambdaschool.schools.services.HelperFunctions;
+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
+ HelperFunctions helperFunctions;
+
+ @Override
+ protected ResponseEntity