[Rt-commit] rt branch, 4.4/dashboard-standard-abort-message, created. rt-4.4.3-44-g5a5f304af

Jim Brandt jbrandt at bestpractical.com
Thu Sep 20 16:50:33 EDT 2018


The branch, 4.4/dashboard-standard-abort-message has been created
        at  5a5f304afdbbad1555fbad8b6c0fb151a4a65f0a (commit)

- Log -----------------------------------------------------------------
commit 5a5f304afdbbad1555fbad8b6c0fb151a4a65f0a
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu Sep 20 16:48:11 2018 -0400

    Standardize error message for failed dashboard load
    
    Display the same message on failed dashboard loads as failed
    ticket loads for consistency and to avoid showing technical details
    to end users. Extra information on the failure is still logged.

diff --git a/share/html/Dashboards/Modify.html b/share/html/Dashboards/Modify.html
index 226318287..e39740880 100644
--- a/share/html/Dashboards/Modify.html
+++ b/share/html/Dashboards/Modify.html
@@ -119,7 +119,10 @@ else {
     }
     else {
         my ($ok, $msg) = $Dashboard->LoadById($id);
-        $ok || Abort(loc("Couldn't load dashboard [_1]: [_2]", $id, $msg));
+        unless ($ok) {
+            RT::Logger->error("Unable to load dashboard with $id: $msg");
+            Abort(loc("Could not load dashboard [_1]", $id), Code => HTTP::Status::HTTP_NOT_FOUND);
+        }
     }
 
     if ($id) {
diff --git a/share/html/Dashboards/Queries.html b/share/html/Dashboards/Queries.html
index 39ada6c7b..8d8d673c2 100644
--- a/share/html/Dashboards/Queries.html
+++ b/share/html/Dashboards/Queries.html
@@ -78,7 +78,10 @@ my @results;
 use RT::Dashboard;
 my $Dashboard = RT::Dashboard->new($session{'CurrentUser'});
 my ($ok, $msg) = $Dashboard->LoadById($id);
-$ok || Abort(loc("Couldn't load dashboard [_1]: [_2]", $id, $msg));
+unless ($ok) {
+    RT::Logger->error("Unable to load dashboard with $id: $msg");
+    Abort(loc("Could not load dashboard [_1]", $id), Code => HTTP::Status::HTTP_NOT_FOUND);
+}
 my $title = loc("Modify the content of dashboard [_1]", $Dashboard->Name);
 
 my %desc_of;
diff --git a/share/html/Dashboards/Render.html b/share/html/Dashboards/Render.html
index acaf6d6d6..86a633b0d 100644
--- a/share/html/Dashboards/Render.html
+++ b/share/html/Dashboards/Render.html
@@ -118,7 +118,10 @@ $m->callback(ARGSRef => \%ARGS,
 use RT::Dashboard;
 my $Dashboard = RT::Dashboard->new($session{'CurrentUser'});
 my ($ok, $msg) = $Dashboard->LoadById($id);
-$ok || Abort(loc("Couldn't load dashboard [_1]: [_2]", $id, $msg));
+unless ($ok) {
+    RT::Logger->error("Unable to load dashboard with $id: $msg");
+    Abort(loc("Could not load dashboard [_1]", $id), Code => HTTP::Status::HTTP_NOT_FOUND);
+}
 
 my $path = '/Dashboards/' . $Dashboard->id . '/' . $Dashboard->Name;
 unless ( $skip_create ) {
diff --git a/share/html/Dashboards/Subscription.html b/share/html/Dashboards/Subscription.html
index 0cb020c1a..654f58ddf 100644
--- a/share/html/Dashboards/Subscription.html
+++ b/share/html/Dashboards/Subscription.html
@@ -221,7 +221,10 @@ my $timezone = $session{'CurrentUser'}->UserObj->Timezone || RT->Config->Get('Ti
 use RT::Dashboard;
 my $Dashboard = RT::Dashboard->new($session{'CurrentUser'});
 my ($ok, $msg) = $Dashboard->LoadById($id);
-$ok || Abort(loc("Couldn't load dashboard [_1]: [_2]", $id, $msg));
+unless ($ok) {
+    RT::Logger->error("Unable to load dashboard with $id: $msg");
+    Abort(loc("Could not load dashboard [_1]", $id), Code => HTTP::Status::HTTP_NOT_FOUND);
+}
 
 my $SubscriptionObj = $Dashboard->Subscription;
 
diff --git a/t/web/dashboards-basics.t b/t/web/dashboards-basics.t
index 024439f13..fd93c6a79 100644
--- a/t/web/dashboards-basics.t
+++ b/t/web/dashboards-basics.t
@@ -2,7 +2,7 @@ use strict;
 use warnings;
 
 use HTTP::Status qw();
-use RT::Test tests => 105;
+use RT::Test tests => undef;
 my ($baseurl, $m) = RT::Test->started_ok;
 
 my $url = $m->rt_base_url;
@@ -170,9 +170,10 @@ $m->content_contains("Deleted dashboard");
 
 $m->get("/Dashboards/Modify.html?id=$id");
 $m->content_lacks("different dashboard", "dashboard was deleted");
-$m->content_contains("Failed to load dashboard $id");
+$m->content_contains("Could not load dashboard $id");
 
-$m->warning_like(qr/Failed to load dashboard.*Couldn't find row/, "the dashboard was deleted");
+$m->next_warning_like(qr/Failed to load dashboard/, "the dashboard was deleted");
+$m->next_warning_like(qr/Could not load dashboard/, "the dashboard was deleted");
 
 $user_obj->PrincipalObj->GrantRight(Right => "SuperUser", Object => $RT::System);
 
@@ -234,7 +235,9 @@ my ($bad_id) = $personal =~ /^search-(\d+)/;
 
 for my $page (qw/Modify Queries Render Subscription/) {
     $m->get("/Dashboards/$page.html?id=$bad_id");
-    $m->content_like(qr/Couldn.+t load dashboard $bad_id: Invalid object type/);
-    $m->warning_like(qr/Couldn't load dashboard $bad_id: Invalid object type/);
+    $m->content_like(qr/Could not load dashboard $bad_id/);
+    $m->next_warning_like(qr/Unable to load dashboard with $bad_id/);
+    $m->next_warning_like(qr/Could not load dashboard $bad_id/);
 }
 
+done_testing();

-----------------------------------------------------------------------


More information about the rt-commit mailing list