diff --git a/hadrian/src/Rules/Documentation.hs b/hadrian/src/Rules/Documentation.hs
index 392d0d9f7ab09f56caefd83aa2bb3a8a26777296..3dc70ac83021422da6913233a04af2cc86f06e15 100644
--- a/hadrian/src/Rules/Documentation.hs
+++ b/hadrian/src/Rules/Documentation.hs
@@ -171,8 +171,14 @@ checkSphinxWarnings out = do
     when ("undefined label:" `isInfixOf` log)
       $ fail "Undefined labels found in Sphinx log."
 
-    when ("ERROR:" `isInfixOf` log)
+    when (any hasError (lines log))
       $ fail "Errors found in the Sphinx log."
+    where
+        hasError line =
+            case words line of
+                _ : "ERROR:" : _ -> True
+                _ : "CRITICAL:" : _ -> True
+                _ -> False
 
 -- | Check that all GHC flags are documented in the users guide.
 checkUserGuideFlags :: FilePath -> Action ()