From 677ce26e6cfaf4ec709311896702371b21c39653 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Wed, 19 Jan 2022 19:57:51 +0100 Subject: [PATCH] Use generic handling of our own exceptions Noticed that we shouldn't be trying to catch specific exceptions as `Dry::Types` will throw its own exceptions for validation errors. --- app/controllers/ajax/relationship_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/ajax/relationship_controller.rb b/app/controllers/ajax/relationship_controller.rb index 8b592c93..bdf0c6c5 100644 --- a/app/controllers/ajax/relationship_controller.rb +++ b/app/controllers/ajax/relationship_controller.rb @@ -17,8 +17,8 @@ class Ajax::RelationshipController < AjaxController ) @response[:success] = true @response[:message] = t("messages.friend.create.okay") - rescue Errors::Base - @response[:message] = t("messages.answer.create.fail") + rescue Errors::Base => e + @response[:message] = t(e.locale_tag) ensure return_response end @@ -31,8 +31,8 @@ class Ajax::RelationshipController < AjaxController ) @response[:success] = true @response[:message] = t("messages.friend.destroy.okay") - rescue Errors::Base - @response[:message] = t("messages.friend.destroy.fail") + rescue Errors::Base => e + @response[:message] = t(e.locale_tag) ensure return_response end