Improve error handling in the case where patch_delete fails.
authorRobert Haas <[email protected]>
Wed, 27 May 2009 00:22:36 +0000 (20:22 -0400)
committerRobert Haas <[email protected]>
Wed, 27 May 2009 00:22:36 +0000 (20:22 -0400)
Per suggestion from Josh Tolley.  Along the way, correct a dubious formatting
choice in template/error.tt2.

perl-lib/PgCommitFest/Patch.pm
template/error.tt2
template/patch_delete.tt2 [new file with mode: 0644]

index b648e4adf07f640bbace9fd462e495836ad2aff0..3cf1e2ac5a293be46523a3a7eab00bf4f48c0123 100644 (file)
@@ -21,11 +21,15 @@ EOM
                $r->redirect('/action/commitfest_view?id=' . $d->{'commitfest_id'});
        }
        if ($err =~ /patch_comment_patch_id_fkey/) {
-               $r->error_exit(<<EOM);
-Because this patch has one or more comments, it may not be deleted.
+               $r->error(<<EOM);
+Because this patch has one or more comments, it may not be deleted.  Unless you
+are an administrator, you may only edit or delete your own comments.
 EOM
        }
-       $r->error_exit("Internal error: $@");
+       else {
+               $r->error("Internal error: $@");
+       }
+       $r->render_template('patch_delete', { 'id' => $r->cgi_required_id });
 }
 
 sub form {
index 6e538fa4d6e6e3d62c5d0d3b0dab1433fa3f7d0c..27feb2177d14854c9783e230e66835233b986a2c 100644 (file)
@@ -1,3 +1,3 @@
 [% FOREACH one_error_in_list = error_list %]
-<p class='error'>[% one_error_in_list | htmlsafe | html_line_break %]</p>
+<p class='error'>[% one_error_in_list | htmlsafe %]</p>
 [% END %]
diff --git a/template/patch_delete.tt2 b/template/patch_delete.tt2
new file mode 100644 (file)
index 0000000..e4868cf
--- /dev/null
@@ -0,0 +1 @@
+<p><a href='/action/patch_view?id=[% id %]'>Return to Patch</a></p>