diff options
author | Philip Sargent <philip.sargent@klebos.com> | 2021-12-30 19:28:33 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@klebos.com> | 2021-12-30 19:28:33 +0000 |
commit | 84e165b8fc17dfa924b549ccd2ad16e2013a596b (patch) | |
tree | f93b2bc51d5a8cbbfb7d1a9a4eca205a5efe62d4 /core/models/caves.py | |
parent | 5bad82b4f0c35fb79c7bcf74da6c943707cc104e (diff) | |
download | troggle-84e165b8fc17dfa924b549ccd2ad16e2013a596b.tar.gz troggle-84e165b8fc17dfa924b549ccd2ad16e2013a596b.tar.bz2 troggle-84e165b8fc17dfa924b549ccd2ad16e2013a596b.zip |
Move exception handling to calling View
Diffstat (limited to 'core/models/caves.py')
-rw-r--r-- | core/models/caves.py | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/core/models/caves.py b/core/models/caves.py index 4d2e0a9..263eaf1 100644 --- a/core/models/caves.py +++ b/core/models/caves.py @@ -45,19 +45,13 @@ def writetrogglefile(filepath, filecontent): filename = filepath.name git = settings.GIT - try: - with open(filepath, "w") as f: - os.chmod(filepath, 0o664) # set file permissions to rw-rw-r-- - f.write(filecontent) - print(f'WRITING{cwd}---{filename} ') - call([git, "add", filename], cwd=cwd) - call([git, "commit", "-m", 'Online cave or entrance edit'], cwd=cwd) - except PermissionError: - message = f'CANNOT save this file.\nPERMISSIONS incorrectly set on server for this file {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 {filename}. Edits not saved.\nAsk a nerd to fix this.' - return render(request,'errors/generic.html', {'message': message}) + # do not trap exceptions, pass them up to the view that called this function + with open(filepath, "w") as f: + os.chmod(filepath, 0o664) # set file permissions to rw-rw-r-- + f.write(filecontent) + print(f'WRITING{cwd}---{filename} ') + call([git, "add", filename], cwd=cwd) + call([git, "commit", "-m", 'Online cave or entrance edit'], cwd=cwd) class Area(TroggleModel): |