mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
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>
This commit is contained in:
parent
fb5c8fd948
commit
54fccd71fb
11
editor.py
11
editor.py
@ -76,8 +76,15 @@ least one of these before using this command."""
|
|||||||
os.close(fd)
|
os.close(fd)
|
||||||
fd = None
|
fd = None
|
||||||
|
|
||||||
if subprocess.Popen(editor + [path]).wait() != 0:
|
try:
|
||||||
raise EditorError()
|
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)
|
fd2 = open(path)
|
||||||
try:
|
try:
|
||||||
return fd2.read()
|
return fd2.read()
|
||||||
|
5
error.py
5
error.py
@ -24,6 +24,11 @@ class ManifestInvalidRevisionError(Exception):
|
|||||||
class EditorError(Exception):
|
class EditorError(Exception):
|
||||||
"""Unspecified error from the user's text editor.
|
"""Unspecified error from the user's text editor.
|
||||||
"""
|
"""
|
||||||
|
def __init__(self, reason):
|
||||||
|
self.reason = reason
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.reason
|
||||||
|
|
||||||
class GitError(Exception):
|
class GitError(Exception):
|
||||||
"""Unspecified internal error from git.
|
"""Unspecified internal error from git.
|
||||||
|
Loading…
Reference in New Issue
Block a user