FIX: Remove custom 'error' action on build-category-route/discovery (#11425)

FIX: Remove custom ‘error’ action on build-category-route/discovery (#11425)

The root cause of the issue was that the route was overriding the ‘error’ action from the correctly implemented handler in routes/application.js.

Remove the custom handler, and the duplicated template logic for displaying the errorHtml.

Fixes: e16b3da04a8be659a035a6ae2f45c1e92799ef9f

diff --git a/app/assets/javascripts/discourse/app/routes/build-category-route.js b/app/assets/javascripts/discourse/app/routes/build-category-route.js
index af741fc..59c9046 100644
--- a/app/assets/javascripts/discourse/app/routes/build-category-route.js
+++ b/app/assets/javascripts/discourse/app/routes/build-category-route.js
@@ -66,17 +66,12 @@ export default (filterArg, params) => {
           parts.pop();
         }
 
-        return Category.reloadBySlugPath(parts.join("/"))
-          .then((result) => {
-            const record = this.store.createRecord("category", result.category);
-            record.setupGroupsAndPermissions();
-            this.site.updateCategory(record);
-            return { category: record, modelParams };
-          })
-          .catch(() => {
-            // afterModel will call replaceWith(/404)
-            return null;
-          });
+        return Category.reloadBySlugPath(parts.join("/")).then((result) => {
+          const record = this.store.createRecord("category", result.category);
+          record.setupGroupsAndPermissions();
+          this.site.updateCategory(record);
+          return { category: record, modelParams };
+        });
       }
 
       if (category) {
@@ -244,18 +239,6 @@ export default (filterArg, params) => {
     },
 
     actions: {
-      error(err) {
-        const json = err.jqXHR.responseJSON;
-        if (json && json.extras && json.extras.html) {
-          this.controllerFor("discovery").set(
-            "errorHtml",
-            err.jqXHR.responseJSON.extras.html
-          );
-        } else {
-          this.replaceWith("exception");
-        }
-      },
-
       setNotification(notification_level) {
         this.currentModel.setNotification(notification_level);
       },
diff --git a/app/assets/javascripts/discourse/app/templates/discovery.hbs b/app/assets/javascripts/discourse/app/templates/discovery.hbs
index 6358886..a5f57bb 100644
--- a/app/assets/javascripts/discourse/app/templates/discovery.hbs
+++ b/app/assets/javascripts/discourse/app/templates/discovery.hbs
@@ -1,41 +1,37 @@
-{{#if errorHtml}}
-  {{html-safe errorHtml}}
-{{else}}
-  <div class="container">
-    {{discourse-banner user=currentUser banner=site.banner}}
-    {{#unless viewingCategoriesList}}
-      {{category-read-only-banner category=category readOnly=navigationCategory.cannotCreateTopicOnCategory}}
-    {{/unless}}
-  </div>
+<div class="container">
+  {{discourse-banner user=currentUser banner=site.banner}}
+  {{#unless viewingCategoriesList}}
+    {{category-read-only-banner category=category readOnly=navigationCategory.cannotCreateTopicOnCategory}}
+  {{/unless}}
+</div>
 
-  <div class="list-controls">
-    <div class="container">
-      {{outlet "navigation-bar"}}
-    </div>
+<div class="list-controls">
+  <div class="container">
+    {{outlet "navigation-bar"}}
   </div>
+</div>
 
-  {{conditional-loading-spinner condition=loading}}
+{{conditional-loading-spinner condition=loading}}
 
-  {{plugin-outlet name="discovery-above"}}
+{{plugin-outlet name="discovery-above"}}
 
-  <div class="container list-container {{if loading "hidden"}}">
-    <div class="row">
-      <div class="full-width">
-        <div id="header-list-area">
-          {{outlet "header-list-container"}}
-        </div>
+<div class="container list-container {{if loading "hidden"}}">
+  <div class="row">
+    <div class="full-width">
+      <div id="header-list-area">
+        {{outlet "header-list-container"}}
       </div>
     </div>
-    <div class="row">
-      <div class="full-width">
-        <div id="list-area">
-          {{plugin-outlet name="discovery-list-container-top"
-                          args=(hash category=category listLoading=loading)}}
-          {{outlet "list-container"}}
-        </div>
+  </div>
+  <div class="row">
+    <div class="full-width">
+      <div id="list-area">
+        {{plugin-outlet name="discovery-list-container-top"
+                        args=(hash category=category listLoading=loading)}}
+        {{outlet "list-container"}}
       </div>
     </div>
   </div>
+</div>
 
-  {{plugin-outlet name="discovery-below"}}
-{{/if}}
+{{plugin-outlet name="discovery-below"}}

GitHub sha: 59ef48c0

This commit appears in #11425 which was approved by featheredtoast and eviltrout. It was merged by riking.