chiark / gitweb /
Use a special exit code for bugs
authorKarl Hasselström <kha@treskal.com>
Thu, 20 Mar 2008 23:12:10 +0000 (23:12 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Thu, 20 Mar 2008 23:12:10 +0000 (23:12 +0000)
Use a special exit code (4) for any error condition that indicates a
bug in StGit. This will be useful in the test suite.

Signed-off-by: Karl Hasselström <kha@treskal.com>
stgit/main.py
stgit/utils.py

index 79044b038e2a02673fa2cbbcfbfccfb5adb10930..663fdec35e7564071ccac54e3bfc319061f7c690 100644 (file)
@@ -18,7 +18,7 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 """
 
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 """
 
-import sys, os
+import sys, os, traceback
 from optparse import OptionParser
 
 import stgit.commands
 from optparse import OptionParser
 
 import stgit.commands
@@ -279,10 +279,13 @@ def main():
     except (StgException, IOError, ParsingError, NoSectionError), err:
         out.error(str(err), title = '%s %s' % (prog, cmd))
         if debug_level > 0:
     except (StgException, IOError, ParsingError, NoSectionError), err:
         out.error(str(err), title = '%s %s' % (prog, cmd))
         if debug_level > 0:
-            raise
-        else:
-            sys.exit(utils.STGIT_COMMAND_ERROR)
+            traceback.print_exc()
+        sys.exit(utils.STGIT_COMMAND_ERROR)
     except KeyboardInterrupt:
         sys.exit(utils.STGIT_GENERAL_ERROR)
     except KeyboardInterrupt:
         sys.exit(utils.STGIT_GENERAL_ERROR)
+    except:
+        out.error('Unhandled exception:')
+        traceback.print_exc()
+        sys.exit(utils.STGIT_BUG_ERROR)
 
     sys.exit(ret or utils.STGIT_SUCCESS)
 
     sys.exit(ret or utils.STGIT_SUCCESS)
index b75c3b4ff0cc07a37cc2c2f7a062722b1f4be07e..cd523826153ba336b7c1b63056a3cae461d02fb8 100644 (file)
@@ -327,6 +327,7 @@ STGIT_SUCCESS = 0        # everything's OK
 STGIT_GENERAL_ERROR = 1  # seems to be non-command-specific error
 STGIT_COMMAND_ERROR = 2  # seems to be a command that failed
 STGIT_CONFLICT = 3       # merge conflict, otherwise OK
 STGIT_GENERAL_ERROR = 1  # seems to be non-command-specific error
 STGIT_COMMAND_ERROR = 2  # seems to be a command that failed
 STGIT_CONFLICT = 3       # merge conflict, otherwise OK
+STGIT_BUG_ERROR = 4      # a bug in StGit
 
 def strip_leading(prefix, s):
     """Strip leading prefix from a string. Blow up if the prefix isn't
 
 def strip_leading(prefix, s):
     """Strip leading prefix from a string. Blow up if the prefix isn't