From f21aca234c1d7ad316289c497241e5b68846989c Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 13 Aug 2024 15:25:58 +1000 Subject: [PATCH] Remove direct dependency on MiniMagick We still depend on it as long as we set it as image processor but now we can switch to another image processor without changing the code around error handling. We now rescue from unknown errors during image processing which should make the app more robust. --- app/models/enterprise.rb | 4 +--- app/models/spree/image.rb | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 9af23e4068..7c88411c05 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -1,7 +1,5 @@ # frozen_string_literal: false -require "mini_magick" - class Enterprise < ApplicationRecord SELLS = %w(unspecified none own any).freeze ENTERPRISE_SEARCH_RADIUS = 100 @@ -479,7 +477,7 @@ class Enterprise < ApplicationRecord return unless image.variable? image_variant_url_for(image.variant(name)) - rescue ActiveStorage::Error, MiniMagick::Error, ActionView::Template::Error => e + rescue StandardError => e Bugsnag.notify "Enterprise ##{id} #{image.try(:name)} error: #{e.message}" Rails.logger.error(e.message) diff --git a/app/models/spree/image.rb b/app/models/spree/image.rb index 77a463c301..45859a6b45 100644 --- a/app/models/spree/image.rb +++ b/app/models/spree/image.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "mini_magick" - module Spree class Image < Asset has_one_attached :attachment, service: image_service do |attachment| @@ -35,7 +33,7 @@ module Spree return self.class.default_image_url(size) unless attachment.attached? image_variant_url_for(variant(size)) - rescue ActiveStorage::Error, MiniMagick::Error, ActionView::Template::Error => e + rescue StandardError => e Bugsnag.notify "Product ##{viewable_id} Image ##{id} error: #{e.message}" Rails.logger.error(e.message)