2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

better error handling

This commit is contained in:
Philip Sargent 2022-07-23 20:05:58 +03:00
parent a1e538e93a
commit 5007393536
2 changed files with 12 additions and 7 deletions

View File

@ -211,9 +211,14 @@ def scanupload(request, path=None):
wallet = "2022#01" # improve this later
year = wallet[:4]
if int(year) <= 1998:
#print(f'! - FORM scanupload - start {wallet} REDIRECT TO OLDWALLET')
try:
if int(year) <= 1998:
#print(f'! - FORM scanupload - start {wallet} REDIRECT TO OLDWALLET')
return(oldwallet(request, path))
except:
# if nonumeric wallet name for example
return(oldwallet(request, path))
if str(wallet).lower().endswith('indexpages'):
# print(f'! - FORM scanupload - start {wallet} REDIRECT TO OLDWALLET')

View File

@ -202,7 +202,7 @@ class LoadingSurvex():
print(self.insp+message)
DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path))
else:
message = "! Bad svx command: [*{}] {} ({}) {}".format(cmd, line, survexblock, survexblock.survexfile.path)
message = "! Bad unrecognised svx command: [*{}] {} ({}) {}".format(cmd, line, survexblock, survexblock.survexfile.path)
print(self.insp+message)
DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path))
@ -313,7 +313,7 @@ class LoadingSurvex():
survexblock.date = datetime.strptime(line, '%Y') # sets to January 1st
setdate(year)
else:
message = "! DATE unrecognised '{}' ({}) {}".format(line, survexblock, survexblock.survexfile.path)
message = "! Error DATE unrecognised '{}' ({}) {}".format(line, survexblock, survexblock.survexfile.path)
print(self.insp+message)
DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path))
@ -424,7 +424,7 @@ class LoadingSurvex():
except:
message = ' ! Value Error: Compass not found in line %s in %s' % (ls, survexblock.survexfile.path)
print(self.insp+message)
DataIssue.objects.create(parser='survexleg', message=message)
DataIssue.objects.create(parser='survexleg', message=message, url=get_offending_filename(survexblock.survexfile.path))
lcompass = invalid_compass
try:
@ -626,7 +626,7 @@ class LoadingSurvex():
# ls = ["normal", "from", "to", "tape", "compass", "clino" ]
for i in range(1, len(ls)): # len[0] is "normal"
if ls[i].lower() =="newline":
message = f" ! - ABORT *data statement has NEWLINE in it in {survexblock.survexfile.path}. Not parsed by torggle. '{args}'"
message = f" ! - ABORT *data statement has NEWLINE in it in {survexblock.survexfile.path}. Not parsed by troggle. '{args}'"
print(message)
print(message,file=sys.stderr)
DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path))
@ -735,7 +735,7 @@ class LoadingSurvex():
#print("\n"+message)
#print("\n"+message,file=sys.stderr)
return
message = f" ! Error: FAILURE '{headpath}' while creating '{includelabel}' at depth:'{depth}'. Not a cave or in the ignore list:'{self.ignoreprefix}'"
message = f" ! Error: FAILURE '{headpath}' while creating '{includelabel}' at depth:[{depth}]. Not a cave or in the ignore list:'{self.ignoreprefix}'"
# getting this triggered for gpx/2018 (cavern error) but not for gpx/2017 (no content).
print("\n"+message)
print("\n"+message,file=sys.stderr)