Commit baf85301 authored by Daniel Brown's avatar Daniel Brown
Browse files

more error handling

parent c01cd0ad
......@@ -50,6 +50,6 @@ class FinesseRunError(BasePyKatException) :
self.__err = err
self.__kat = kat
BasePyKatException.__init__(self, "Finesse error (file {1}):\n{0}".format(self.__err, self.__kat))
BasePyKatException.__init__(self, self.__err)
#BasePyKatException.__init__(self, "{0}".format(self.__err))
......@@ -554,6 +554,8 @@ class kat(object):
Before fully parsing a bunch of commands firstly any constants or variables
to be recorded and replaced.
"""
try:
constants = self.constants
for line in commands:
......@@ -602,6 +604,10 @@ class kat(object):
return commands_new
except pkex.BasePyKatException as ex:
pkex.PrintError("Error processing constants:", ex)
sys.exit(1)
def parseCommands(self, commands, blocks=None):
try:
blockComment = False
......@@ -1007,6 +1013,7 @@ class kat(object):
line = unicode(aline, "utf-8")
else:
line = aline
if len(line) > 0:
# remove any ANSI commands
#ansi = re.compile(r'\x1b[^m]*m')
......@@ -1026,12 +1033,14 @@ class kat(object):
sys.stdout.write("\r{0} {1}".format(action, prc))
else:
sys.stdout.write("\r{0} {1}".format(str(action, 'utf-8'), str(prc, 'utf-8')))
elif line.lstrip().startswith(b'*'):
if self.verbose:
if six.PY2:
sys.stdout.write(line)
else:
sys.stdout.write(str(line,'utf-8'))
elif line.rstrip().endswith(b'%'):
vals = line.split("-")
action = vals[0].strip()
......@@ -1066,8 +1075,7 @@ class kat(object):
# If Finesse returned an error, just print that and exit!
if p.returncode != 0:
print (err)
sys.exit(1)
raise pkex.FinesseRunError(err, katfile.name)
self.__prevrunfilename = katfile.name
......@@ -1140,8 +1148,10 @@ class kat(object):
else:
return r
except pkex.FinesseRunError as fe:
print (fe)
except pkex.FinesseRunError as ex:
pkex.PrintError("Error from Finesse:", ex)
except pkex.BasePyKatException as ex:
pkex.PrintError("Error from pykat:", ex)
finally:
if self.verbose: print ("")
if self.verbose: print ("Finished in " + str(datetime.datetime.now()-start))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment