diff --git a/app/components/add_tag_rule_modal_component/add_tag_rule_modal_controller.js b/app/components/add_tag_rule_modal_component/add_tag_rule_modal_controller.js index 85f9b71141..87af93f7ec 100644 --- a/app/components/add_tag_rule_modal_component/add_tag_rule_modal_controller.js +++ b/app/components/add_tag_rule_modal_component/add_tag_rule_modal_controller.js @@ -1,4 +1,5 @@ import { Controller } from "stimulus"; +import showHttpError from "../../webpacker/js/services/show_http_error"; export default class extends Controller { static targets = ["rule", "ruleCustomerTag"]; @@ -29,11 +30,17 @@ export default class extends Controller { Accept: "text/vnd.turbo-stream.html", }, }) - .then((r) => r.text()) + .then((response) => { + if (!response.ok) { + showHttpError(response.status); + throw response; + } + return response.text(); + }) .then((html) => { Turbo.renderStreamMessage(html); this.indexValue = parseInt(index) + 1; }) - .catch((error) => console.warn(error)); + .catch((error) => console.error(error)); } } diff --git a/app/webpacker/controllers/tag_rule_group_controller.js b/app/webpacker/controllers/tag_rule_group_controller.js index 640609d7a8..407b561c8e 100644 --- a/app/webpacker/controllers/tag_rule_group_controller.js +++ b/app/webpacker/controllers/tag_rule_group_controller.js @@ -1,4 +1,5 @@ import { Controller } from "stimulus"; +import showHttpError from "../../webpacker/js/services/show_http_error"; export default class extends Controller { static targets = ["index", "customerRuleIndex"]; @@ -19,11 +20,17 @@ export default class extends Controller { Accept: "text/vnd.turbo-stream.html", }, }) - .then((r) => r.text()) + .then((response) => { + if (!response.ok) { + showHttpError(response.status); + throw response; + } + return response.text(); + }) .then((html) => { Turbo.renderStreamMessage(html); this.indexTarget.value = parseInt(index) + 1; }) - .catch((error) => console.warn(error)); + .catch((error) => console.error(error)); } }