git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org, Erik Sandberg <mandolaerik@gmail.com>
Subject: [StGit PATCH 1/6] Use a special exit code for bugs
Date: Thu, 20 Mar 2008 01:31:34 +0100	[thread overview]
Message-ID: <20080320003134.13102.73631.stgit@yoghurt> (raw)
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

  reply	other threads:[~2008-03-20  0:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-20  0:31 [StGit PATCH 0/6] Two bugfixes Karl Hasselström
2008-03-20  0:31 ` Karl Hasselström [this message]
2008-03-20  0:31 ` [StGit PATCH 2/6] Make sure patches with no parents have an empty list of parents Karl Hasselström
2008-03-20  0:31 ` [StGit PATCH 3/6] Try uncommitting a commit with not exactly one parent Karl Hasselström
2008-03-20  0:31 ` [StGit PATCH 4/6] Make sure that we only uncommit commits with " Karl Hasselström
2008-03-20  0:31 ` [StGit PATCH 5/6] New test: conflicting push in dirty worktree Karl Hasselström
2008-03-20  0:32 ` [StGit PATCH 6/6] Handle failed pushes differently depending on cause Karl Hasselström
2008-03-20 15:19 ` [StGit PATCH 0/6] Two bugfixes Catalin Marinas
2008-03-24  8:35   ` Karl Hasselström
2008-03-24  9:16     ` Catalin Marinas
2008-03-24 18:12   ` Karl Hasselström
2008-03-25 10:46     ` Catalin Marinas
2008-03-25 11:05       ` Karl Hasselström
2008-03-25 15:27         ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080320003134.13102.73631.stgit@yoghurt \
    --to=kha@treskal.com \
    --cc=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=mandolaerik@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).