summaryrefslogtreecommitdiffstats
path: root/custodia/store
diff options
context:
space:
mode:
Diffstat (limited to 'custodia/store')
-rw-r--r--custodia/store/interface.py4
-rw-r--r--custodia/store/sqlite.py6
2 files changed, 8 insertions, 2 deletions
diff --git a/custodia/store/interface.py b/custodia/store/interface.py
index 3c7d620..5a7db93 100644
--- a/custodia/store/interface.py
+++ b/custodia/store/interface.py
@@ -5,6 +5,10 @@ class CSStoreError(Exception):
pass
+class CSStoreExists(Exception):
+ pass
+
+
class CSStore(object):
def get(self, key):
diff --git a/custodia/store/sqlite.py b/custodia/store/sqlite.py
index 481313e..f321678 100644
--- a/custodia/store/sqlite.py
+++ b/custodia/store/sqlite.py
@@ -1,7 +1,7 @@
# Copyright (C) 2015 Custodia Project Contributors - see LICENSE file
from __future__ import print_function
-from custodia.store.interface import CSStore, CSStoreError
+from custodia.store.interface import CSStore, CSStoreError, CSStoreExists
import os
import sqlite3
import sys
@@ -54,6 +54,8 @@ class SqliteStore(CSStore):
c = conn.cursor()
self._create(c)
c.execute(setdata, (key, value))
+ except sqlite3.IntegrityError as err:
+ raise CSStoreExists(str(err))
except sqlite3.Error as err:
log_error("Error storing key %s: [%r]" % (key, repr(err)))
raise CSStoreError('Error occurred while trying to store key')
@@ -182,7 +184,7 @@ class SqliteStoreTests(unittest.TestCase):
self.assertEqual(value, None)
def test_5_set_replace(self):
- with self.assertRaises(CSStoreError):
+ with self.assertRaises(CSStoreExists):
self.store.set('key', 'replaced')
self.store.set('key', 'replaced', replace=True)