2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-01-31 07:22:32 +00:00

let exceptions bubble up

This commit is contained in:
Philip Sargent 2021-12-30 19:46:44 +00:00
parent 84e165b8fc
commit 0a3037f077
2 changed files with 13 additions and 9 deletions

View File

@ -39,7 +39,9 @@ todo='''- Move utility function into utils.py
'''
def writetrogglefile(filepath, filecontent):
'''Set permissions to rw-rw-r-- and commit the new saved file to git'''
'''Set permissions to rw-rw-r-- and commit the new saved file to git
Callers should handle exception PermissionsError explicitly
'''
filepath = Path(filepath)
cwd = filepath.parent
filename = filepath.name

View File

@ -359,14 +359,16 @@ def edit_cave(request, slug=None):
for ceinst in ceinsts:
ceinst.cave = cave
ceinst.save()
try:
cave.writeDataFile()
except PermissionError:
message = f'CANNOT save this file.\nPERMISSIONS incorrectly set on server for this file {cave.filename}. Ask a nerd to fix this.'
return render(request,'errors/generic.html', {'message': message})
except:
message = f'CANNOT git on server for this file {cave.filename}. Edits not saved.\nAsk a nerd to fix this.'
return render(request,'errors/generic.html', {'message': message})
cave.writeDataFile()
# try:
# cave.writeDataFile()
# except PermissionError:
# message = f'CANNOT save this file.\nPERMISSIONS incorrectly set on server for this file {cave.filename}. Ask a nerd to fix this.'
# return render(request,'errors/generic.html', {'message': message})
# leave other exeptions unhandled so that they bubble up to userinterface
# except:
# message = f'CANNOT git on server for this file {cave.filename}. Edits not saved.\nAsk a nerd to fix this.'
# return render(request,'errors/generic.html', {'message': message})
return HttpResponseRedirect("/" + cave.url)
else: