git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[StGit PATCH 1/6] Use a special exit code for bugs

From
Karl Hasselström <kha@treskal.com>
Date
Mar 20, 2008, 00:31 UTC
Message-ID
<20080320003134.13102.73631.stgit@yoghurt>
In-Reply-To
<20080320002604.13102.53757.stgit@yoghurt>

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  |   11 +++++++----
 stgit/utils.py |    1 +
 2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/stgit/main.py b/stgit/main.py
index 79044b0..663fdec 100644
--- a/stgit/main.py
+++ b/stgit/main.py
@@ -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
 """
 
-import sys, os
+import sys, os, traceback
 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:
-            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:
+        out.error('Unhandled exception:')
+        traceback.print_exc()
+        sys.exit(utils.STGIT_BUG_ERROR)
 
     sys.exit(ret or utils.STGIT_SUCCESS)
diff --git a/stgit/utils.py b/stgit/utils.py
index b75c3b4..cd52382 100644
--- a/stgit/utils.py
+++ b/stgit/utils.py
@@ -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_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
Previous: Karl HasselströmNext: Karl Hasselström
Message 2 of 14 in “Two bugfixes”
  1. 0/6 Two bugfixesKarl Hasselström, Mar 20, 2008
  2. 1/6 Use a special exit code for bugsKarl Hasselström, Mar 20, 2008
  3. 2/6 Make sure patches with no parents have an empty list of parentsKarl Hasselström, Mar 20, 2008
  4. 3/6 Try uncommitting a commit with not exactly one parentKarl Hasselström, Mar 20, 2008
  5. 4/6 Make sure that we only uncommit commits with exactly one parentKarl Hasselström, Mar 20, 2008
  6. 5/6 New test: conflicting push in dirty worktreeKarl Hasselström, Mar 20, 2008
  7. 6/6 Handle failed pushes differently depending on causeKarl Hasselström, Mar 20, 2008
  8. Catalin MarinasMar 20, 2008
  9. Karl HasselströmMar 24, 2008
  10. Catalin MarinasMar 24, 2008
  11. Karl HasselströmMar 24, 2008
  12. Catalin MarinasMar 25, 2008
  13. Karl HasselströmMar 25, 2008
  14. Catalin MarinasMar 25, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.