stdio: add machinery to identify failed stdout/stderr writes
authorBryan O'Sullivan <bryano@fb.com>
Tue, 11 Apr 2017 14:54:12 -0700
changeset 31959 b445a3f00528
parent 31958 de5c9d0e02ea
child 31960 71dcd4a4fa2f
stdio: add machinery to identify failed stdout/stderr writes Mercurial currently fails to notice failures to write to stdout or stderr. A correctly functioning command line tool should detect this and exit with an error code. To achieve this, we need a little extra plumbing, which we start adding here.
mercurial/error.py
--- a/mercurial/error.py	Tue Apr 11 14:54:12 2017 -0700
+++ b/mercurial/error.py	Tue Apr 11 14:54:12 2017 -0700
@@ -122,6 +122,12 @@
 class RequirementError(RepoError):
     """Exception raised if .hg/requires has an unknown entry."""
 
+class StdioError(IOError):
+    """Raised if I/O to stdout or stderr fails"""
+
+    def __init__(self, err):
+        IOError.__init__(self, err.errno, err.strerror)
+
 class UnsupportedMergeRecords(Abort):
     def __init__(self, recordtypes):
         from .i18n import _