# [PATCH] Catch more exceptions in compat_log_entry()

2 messages from 2013-10-22 to 2013-11-06. Participants: Pavel Roskin, Catalin Marinas.
Thread: https://gitlist.dev/t/35180

## Pavel Roskin, 2013-10-22 14:31

Subject: [PATCH] Catch more exceptions in compat_log_entry()
Message-ID: <20131022143126.11775.85272.stgit@IRBT4585>
URL: https://gitlist.dev/e/20131022143126.11775.85272.stgit%40IRBT4585

```
Catch exceptions in default_repo().  Catch git.RepositoryException.
This suppresses stack trace in "stg pull" on detached head and outside
the repository.

Signed-off-by: Pavel Roskin <proski@gnu.org>
---
 stgit/lib/log.py |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/stgit/lib/log.py b/stgit/lib/log.py
index dfadd51..d876ff6 100644
--- a/stgit/lib/log.py
+++ b/stgit/lib/log.py
@@ -359,10 +359,10 @@ class Fakestack(object):
 def compat_log_entry(msg):
     """Write a new log entry. (Convenience function intended for use by
     code not yet converted to the new infrastructure.)"""
-    repo = default_repo()
     try:
+        repo = default_repo()
         stack = repo.get_stack(repo.current_branch_name)
-    except libstack.StackException, e:
+    except (libstack.StackException, git.RepositoryException), e:
         out.warn(str(e), 'Could not write to stack log')
     else:
         if repo.default_index.conflicts() and stack.patchorder.applied:

```

## Catalin Marinas, 2013-11-06 10:27

Subject: Re: [PATCH] Catch more exceptions in compat_log_entry()
Message-ID: <CAHkRjk5g-UKDN5by0+0xHZBAH8=bhP8yoiGbm1Zdd6L1rQ3Ogg@mail.gmail.com>
URL: https://gitlist.dev/e/CAHkRjk5g-UKDN5by0%2B0xHZBAH8%3DbhP8yoiGbm1Zdd6L1rQ3Ogg%40mail.gmail.com
In-Reply-To: <20131022143126.11775.85272.stgit@IRBT4585>

```
On 22 October 2013 15:31, Pavel Roskin <proski@gnu.org> wrote:
> Catch exceptions in default_repo().  Catch git.RepositoryException.
> This suppresses stack trace in "stg pull" on detached head and outside
> the repository.
>
> Signed-off-by: Pavel Roskin <proski@gnu.org>

Thanks. Applied.

Catalin

```
