From 59b634498b56e1694b479bc05249cf0256aa9842 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Thu, 24 Jan 2019 14:03:55 +0000 Subject: [PATCH] Moved LockError into exceptions.py --- openflexure_microscope/exceptions.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/openflexure_microscope/exceptions.py b/openflexure_microscope/exceptions.py index 250eae65..73db926f 100644 --- a/openflexure_microscope/exceptions.py +++ b/openflexure_microscope/exceptions.py @@ -1,2 +1,20 @@ +from threading import ThreadError + class TaskDeniedException(Exception): - pass \ No newline at end of file + pass + +class LockError(ThreadError): + ERROR_CODES = { + 'ACQUIRE_ERROR': "Unable to acquire. Lock in use by another thread.", + 'IN_USE_ERROR': "Lock in use by another thread." + } + + def __init__(self, code, lock): + self.code = code + if code in LockError.ERROR_CODES: + self.message = LockError.ERROR_CODES[code] + else: + self.message = "Unknown error." + print("{}: {}".format(self.code, self.message)) + + ThreadError.__init__(self) \ No newline at end of file