timestamp: do not traceback on timestamping error, just log them

This commit is contained in:
Benjamin Dauvergne 2013-01-04 10:51:39 +01:00
parent b40c86cc2d
commit c3b2d05505
2 changed files with 8 additions and 2 deletions

View File

@ -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:

View File

@ -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.',