diff --git a/tools/check.py b/tools/check.py
index 2186d1402522db898823b1cbc039034d2b25a350..1c1fc59ce02c2e97bfcae81c0ea1f0e024ae16bd 100755
--- a/tools/check.py
+++ b/tools/check.py
@@ -13,6 +13,7 @@ Call at command line with flag -h to see options and usage instructions.
 
 import argparse
 import collections
+import functools
 import glob
 import hashlib
 import logging
@@ -25,6 +26,19 @@ import yaml
 
 import validation_helpers as vh
 
+NUMBER_OF_ERRORS = 0
+
+def incr_error(func):
+    """Wrapper to count the number of errors"""
+    @functools.wraps(func)
+    def wrapper(*args, **kwargs):
+        global NUMBER_OF_ERRORS
+        NUMBER_OF_ERRORS += 1
+        return func(*args, **kwargs)
+    return wrapper
+
+logging.error = incr_error(logging.error)
+
 
 class MarkdownValidator(object):
     """Base class for Markdown validation
@@ -822,12 +836,11 @@ def main(parsed_args_obj):
 
     if all_valid is True:
         logging.debug("All Markdown files successfully passed validation.")
-        sys.exit(0)
     else:
         logging.warning(
-            "Some errors were encountered during validation. "
-            "See log for details.")
-        sys.exit(1)
+            "{0} errors were encountered during validation. "
+            "See log for details.".format(NUMBER_OF_ERRORS))
+    sys.exit(NUMBER_OF_ERRORS)
 
 
 if __name__ == "__main__":