lib/much-rails/destroy_service.rb in much-rails-0.3.0 vs lib/much-rails/destroy_service.rb in much-rails-0.4.0

- old
+ new

@@ -1,12 +1,14 @@ # frozen_string_literal: true +require "much-rails/invalid_error" require "much-rails/mixin" require "much-rails/records" require "much-rails/records/validate_destroy" require "much-rails/result" require "much-rails/service" +require "much-rails/service_validation_errors" module MuchRails; end # MuchRails::DestroyService is a common mix-in for all service objects that # destroy records. @@ -47,9 +49,16 @@ MuchRails::DestroyService::FailureResult.new( record: ex.record, exception: ex, validation_errors: ex.errors.to_h, validation_error_messages: ex.error_full_messages.to_a, + ) + end + e.add(MuchRails::InvalidError) do |ex| + MuchRails::SaveService::FailureResult.new( + exception: ex, + validation_errors: ex.errors, + validation_error_messages: ex.error_messages, ) end end end end