diff --git a/gracedb/superevents/api/exceptions.py b/gracedb/superevents/api/exceptions.py
index 32ede5de4368fae684863993aefe032ca1c7475b..07c86d032de2f9a8546d0832984ddd6dd563e83a 100644
--- a/gracedb/superevents/api/exceptions.py
+++ b/gracedb/superevents/api/exceptions.py
@@ -1,21 +1,25 @@
+import logging
+
 from rest_framework.views import exception_handler
 
-import logging
+# Set up logger
 logger = logging.getLogger(__name__)
 
+
 def gracedb_exception_handler(exc, context):
     # Call REST framework's default exception handler first,
     # to get the standard error response.
     response = exception_handler(exc, context)
 
-    # Combine values into one list
-    exc_out = [item for sublist in exc.detail.values() for item in sublist]
+    if hasattr(exc, 'detail') and hasattr(exc.detail, 'values'):
+        # Combine values into one list
+        exc_out = [item for sublist in exc.detail.values() for item in sublist]
 
-    # For only one exception, just print it rather than the list
-    if len(exc_out) == 1:
-        exc_out = exc_out[0]
+        # For only one exception, just print it rather than the list
+        if len(exc_out) == 1:
+            exc_out = exc_out[0]
 
-    # Update response data
-    response.data = exc_out
+        # Update response data
+        response.data = exc_out
 
     return response