diff --git a/project/SparkBuild.scala b/project/SparkBuild.scala
index 550b5bad8a46a8e7d515056d86839bb5c22343ea..6eba58c87c39c3a0e2988d8a1f4ef90b2d500112 100644
--- a/project/SparkBuild.scala
+++ b/project/SparkBuild.scala
@@ -433,9 +433,12 @@ object Catalyst {
       }
 
       // Generate the parser.
-      antlr.process
-      if (antlr.getNumErrors > 0) {
-        log.error("ANTLR: Caught %d build errors.".format(antlr.getNumErrors))
+      antlr.process()
+      val errorState = org.antlr.tool.ErrorManager.getErrorState
+      if (errorState.errors > 0) {
+        sys.error("ANTLR: Caught %d build errors.".format(errorState.errors))
+      } else if (errorState.warnings > 0) {
+        sys.error("ANTLR: Caught %d build warnings.".format(errorState.warnings))
       }
 
       // Return all generated java files.