Feed errors that occur in the back end in the backend_status field
[plstackapi.git] / planetstack / observer / error_mapper.py
diff --git a/planetstack/observer/error_mapper.py b/planetstack/observer/error_mapper.py
new file mode 100644 (file)
index 0000000..a7daa59
--- /dev/null
@@ -0,0 +1,25 @@
+from planetstack.config import Config
+from util.logger import Logger, logging, logger
+
+class ErrorMapper:
+       def __init__(self, error_map_file):
+               self.error_map = {}
+               try:
+                       error_map_lines = open(error_map_file).read().splitlines()
+                       for l in error_map_lines:
+                               if (not l.startswith('#')):
+                                       splits = l.split('->')
+                                       k,v = map(lambda i:i.rstrip(),splits)
+                                       self.error_map[k]=v
+               except:
+                       logging.info('Could not read error map')
+
+
+       def map(self, error):
+               return self.error_map[error]
+
+
+
+
+
+