From c3b2d055055a95d1bc3dfe4c9c1e21e77d417d0a Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Fri, 4 Jan 2013 10:51:39 +0100 Subject: [PATCH] timestamp: do not traceback on timestamping error, just log them --- docbow_project/docbow/timestamp.py | 5 ++++- docbow_project/docbow/views.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docbow_project/docbow/timestamp.py b/docbow_project/docbow/timestamp.py index e8e3467..2004619 100644 --- a/docbow_project/docbow/timestamp.py +++ b/docbow_project/docbow/timestamp.py @@ -15,7 +15,10 @@ def timestamp_json(json_dict): s = simplejson.dumps(json_dict) if s[-1] != '}': raise ValueError("timestamp_json takes a dictionnary as argument: %s" % s) - tst, error = timestamp(s) + try: + tst, error = timestamp(s) + except Exception, e: + raise RuntimeError("unable to communicate with timestamping service", e) if tst: return s[:-1] + ',"timestamp": "%s"}' % tst.encode('base64').strip() else: diff --git a/docbow_project/docbow/views.py b/docbow_project/docbow/views.py index e85de29..05e53a5 100644 --- a/docbow_project/docbow/views.py +++ b/docbow_project/docbow/views.py @@ -229,7 +229,10 @@ def send_file(request): 'have been informed.')) else: blob = new_send.timestamp_blob() - tst = timestamp.timestamp_json(blob) + try: + tst = timestamp.timestamp_json(blob) + except (ValueError, RuntimeError), e: + tst = "Error: %r" % str(e) logger.info('sent %s, timestamp %s' % (new_send, tst)) msg = ungettext( 'New document sent to %d recipient.',