Permalink
Browse files

Document any crashes from the user's text editor

Rather than failing with no information, display the child exit
status and the command line we tried to use to edit a text file.
There may be some useful information to help understand the crash.

Signed-off-by: Shawn O. Pearce <sop@google.com>
  • Loading branch information...
1 parent fb5c8fd commit 54fccd71fbdc60adf99b9a9bf4712c121d4312ba @spearce spearce committed Jun 24, 2009
Showing with 14 additions and 2 deletions.
  1. +9 −2 editor.py
  2. +5 −0 error.py
View
@@ -76,8 +76,15 @@ def EditString(cls, data):
os.close(fd)
fd = None
- if subprocess.Popen(editor + [path]).wait() != 0:
- raise EditorError()
+ try:
+ rc = subprocess.Popen(editor + [path]).wait()
+ except OSError, e:
+ raise EditorError('editor failed, %s: %s %s'
+ % (str(e), cls._GetEditor(), path))
+ if rc != 0:
+ raise EditorError('editor failed with exit status %d: %s %s'
+ % (rc, cls._GetEditor(), path))
+
fd2 = open(path)
try:
return fd2.read()
View
@@ -24,6 +24,11 @@ class ManifestInvalidRevisionError(Exception):
class EditorError(Exception):
"""Unspecified error from the user's text editor.
"""
+ def __init__(self, reason):
+ self.reason = reason
+
+ def __str__(self):
+ return self.reason
class GitError(Exception):
"""Unspecified internal error from git.

0 comments on commit 54fccd7

Please sign in to comment.