blob: 8bb02d3821950e77515e09559b1c97b00e2d3e20 [file] [log] [blame]
Scott Bakerb63ea792016-08-11 10:24:48 -07001from xos.logger import Logger, logging, logger
2
Matteo Scandoloceccb1f2017-06-05 10:35:44 -07003
Scott Bakerb63ea792016-08-11 10:24:48 -07004class ErrorMapper:
Matteo Scandoloceccb1f2017-06-05 10:35:44 -07005 def __init__(self, error_map_file):
6 self.error_map = {}
7 try:
8 error_map_lines = open(error_map_file).read().splitlines()
9 for l in error_map_lines:
10 if (not l.startswith('#')):
11 splits = l.split('->')
12 k, v = map(lambda i: i.rstrip(), splits)
13 self.error_map[k] = v
14 except:
15 logging.info('Could not read error map')
Scott Bakerb63ea792016-08-11 10:24:48 -070016
Matteo Scandoloceccb1f2017-06-05 10:35:44 -070017 def map(self, error):
18 return self.error_map[error]