summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2014-01-06 10:29:43 -0200
committerdrebs <drebs@leap.se>2014-01-06 10:29:43 -0200
commit89d3e4a1321ff9701ac67933f8e649cfecd1d95e (patch)
tree268983c0ac554860c39f25a7521fe45bc816aab7 /common
parenta2fc60a03f701abd2309dee23c383f1189ce3cf4 (diff)
Add proper error reporting to shared db lock.
Diffstat (limited to 'common')
-rw-r--r--common/changes/bug_4435_add-lock-timeout-error1
-rw-r--r--common/src/leap/soledad/common/errors.py14
2 files changed, 14 insertions, 1 deletions
diff --git a/common/changes/bug_4435_add-lock-timeout-error b/common/changes/bug_4435_add-lock-timeout-error
new file mode 100644
index 00000000..8f220b1d
--- /dev/null
+++ b/common/changes/bug_4435_add-lock-timeout-error
@@ -0,0 +1 @@
+ o Add lock timeout HTTP error (#4435).
diff --git a/common/src/leap/soledad/common/errors.py b/common/src/leap/soledad/common/errors.py
index 7c2d7296..62de19f8 100644
--- a/common/src/leap/soledad/common/errors.py
+++ b/common/src/leap/soledad/common/errors.py
@@ -57,14 +57,26 @@ class AlreadyLockedError(errors.U1DBError):
wire_description = "lock is locked"
status = 403
+
+class LockTimedOutError(errors.U1DBError):
+ """
+ Exception raised when timing out while trying to lock the shared database.
+ """
+
+ wire_description = "lock timed out"
+ status = 408
+
+
# update u1db "wire description to status" and "wire description to exception"
# maps.
-for e in [InvalidTokenError, NotLockedError, AlreadyLockedError]:
+for e in [InvalidTokenError, NotLockedError, AlreadyLockedError,
+ LockTimedOutError]:
http_errors.wire_description_to_status.update({
e.wire_description: e.status})
errors.wire_description_to_exc.update({
e.wire_description: e})
+
# u1db error statuses also have to be updated
http_errors.ERROR_STATUSES = set(
http_errors.wire_description_to_status.values())