Sha256: 16b9dc1a2d3ade67c672ddde9b469640438b9b21a9037d0426d00ad1279d5e61

Contents?: true

Size: 913 Bytes

Versions: 2

Compression:

Stored size: 913 Bytes

Contents

module StrongMigrations
  module MigrationContext
    def up(...)
      super
    rescue => e
      strong_migrations_process_exception(e)
    end

    def down(...)
      super
    rescue => e
      strong_migrations_process_exception(e)
    end

    def run(...)
      super
    rescue => e
      strong_migrations_process_exception(e)
    end

    private

    def strong_migrations_process_exception(e)
      if e.cause.is_a?(StrongMigrations::Error)
        # strip cause and clean backtrace
        def e.cause
          nil
        end

        def e.message
          super.sub("\n\n\n", "\n\n") + "\n"
        end

        unless Rake.application.options.trace
          def e.backtrace
            bc = ActiveSupport::BacktraceCleaner.new
            bc.add_silencer { |line| line =~ /strong_migrations/ }
            bc.clean(super)
          end
        end
      end

      raise e
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
strong_migrations-2.2.0 lib/strong_migrations/migration_context.rb
strong_migrations-2.1.0 lib/strong_migrations/migration_context.rb