Sha256: 523f532b9d7dc40117cc19d61792d1632cdea8bc7fe25e59588b286dc09aa586

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

# encoding: utf-8
module Dynamoid
  
  # All the errors specific to Dynamoid.  The goal is to mimic ActiveRecord.
  module Errors
    
    # Generic Dynamoid error
    class Error < StandardError; end
    
    class MissingRangeKey < Error; end

    # This class is intended to be private to Dynamoid.
    class ConditionalCheckFailedException < Error
      attr_reader :inner_exception

      def initialize(inner)
        super
        @inner_exception = inner
      end
    end

    class RecordNotUnique < ConditionalCheckFailedException
      attr_reader :original_exception

      def initialize(original_exception, record)
        super("Attempted to write record #{record} when its key already exists")
        @original_exception = original_exception
      end
    end

    class StaleObjectError < ConditionalCheckFailedException
      attr_reader :record, :attempted_action

      def initialize(record, attempted_action)
        super("Attempted to #{attempted_action} a stale object #{record}")
        @record = record
        @attempted_action = attempted_action
      end
    end

    class DocumentNotValid < Error
      def initialize(document)
        super("Validation failed: #{document.errors.full_messages.join(", ")}")
      end
    end

    class InvalidQuery < Error; end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dynamoid-1.1.0 lib/dynamoid/errors.rb
dynamoid-1.0.0 lib/dynamoid/errors.rb