Sha256: 781885c98fc56e94e24457bbfaa3f560634332d551427c612a25d4c322873258

Contents?: true

Size: 473 Bytes

Versions: 7

Compression:

Stored size: 473 Bytes

Contents

class Tram::Policy
  # An exception to be risen by [Tram::Policy#validate!]
  class ValidationError < RuntimeError
    # Policy object whose validation has caused the exception
    #
    # @return [Tram::Policy]
    #
    attr_reader :policy

    private

    def initialize(policy, filter)
      @policy  = policy
      messages = policy.errors.to_a.reject(&filter).map(&:message)
      super (["Validation failed with errors:"] + messages).join("\n- ")
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tram-policy-2.2.0 lib/tram/policy/validation_error.rb
tram-policy-2.1.0 lib/tram/policy/validation_error.rb
tram-policy-2.0.1 lib/tram/policy/validation_error.rb
tram-policy-2.0.0 lib/tram/policy/validation_error.rb
tram-policy-1.0.1 lib/tram/policy/validation_error.rb
tram-policy-1.0.0 lib/tram/policy/validation_error.rb
tram-policy-0.4.0 lib/tram/policy/validation_error.rb