diff options
author | Magnus Hagander | 2015-08-27 07:53:38 +0000 |
---|---|---|
committer | Magnus Hagander | 2015-08-27 07:53:38 +0000 |
commit | 85b6326fd7806e19d15bf8198fa4e9f0f16b7c30 (patch) | |
tree | 2bf96fa5fb8999646924f9c87e65886c726b6512 /pgcommitfest/commitfest/views.py | |
parent | e77924e8e8c2de8956d45655e019d433c36343c3 (diff) |
Don't raise exceptions for "normal errors"
Exceptions will not show the actual error message on the site, only
send an email to the admins with it. Thus, anything that can normally
happen due to a user error should not use that. Instead of that, use
the messages framework so it renders on the next page.
Diffstat (limited to 'pgcommitfest/commitfest/views.py')
-rw-r--r-- | pgcommitfest/commitfest/views.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index 30990e0..02567f3 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -455,20 +455,25 @@ def close(request, cfid, patchid, status): # future one. newcf = CommitFest.objects.filter(status=CommitFest.STATUS_FUTURE) if len(newcf) == 0: - raise Exception("No open and no future commitfest exists!") + messages.error(request,"No open and no future commitfest exists!") + return HttpResponseRedirect('/%s/%s/' % (poc.commitfest.id, poc.patch.id)) elif len(newcf) != 1: - raise Exception("No open and multiple future commitfests exist!") + messages.error(request, "No open and multiple future commitfests exist!") + return HttpResponseRedirect('/%s/%s/' % (poc.commitfest.id, poc.patch.id)) elif len(newcf) != 1: - raise Exception("Multiple open commitfests exists!") + messages.error(request, "Multiple open commitfests exists!") + return HttpResponseRedirect('/%s/%s/' % (poc.commitfest.id, poc.patch.id)) elif newcf[0] == poc.commitfest: # The current open CF is the same one that we are already on. # In this case, try to see if there is a future CF we can # move it to. newcf = CommitFest.objects.filter(status=CommitFest.STATUS_FUTURE) if len(newcf) == 0: - raise Exception("Cannot move patch to the same commitfest, and no future commitfests exist!") + messages.error(request, "Cannot move patch to the same commitfest, and no future commitfests exist!") + return HttpResponseRedirect('/%s/%s/' % (poc.commitfest.id, poc.patch.id)) elif len(newcf) != 1: - raise Exception("Cannot move patch to the same commitfest, and multiple future commitfests exist!") + messages.error(request, "Cannot move patch to the same commitfest, and multiple future commitfests exist!") + return HttpResponseRedirect('/%s/%s/' % (poc.commitfest.id, poc.patch.id)) # Create a mapping to the new commitfest that we are bouncing # this patch to. newpoc = PatchOnCommitFest(patch=poc.patch, commitfest=newcf[0], enterdate=datetime.now()) |