Sha256: 1b4d3bb9987fc6e5e726f694407b9e56fa8a4be730a4995bb0dc889d8bebd77d

Contents?: true

Size: 957 Bytes

Versions: 2

Compression:

Stored size: 957 Bytes

Contents

module Toy
  class Error < StandardError; end

  class RecordInvalidError < Error
    attr_reader :record
    def initialize(record)
      @record = record
      super("Invalid record: #{@record.errors.full_messages.to_sentence}")
    end
  end

  class NotFound < Error
    def initialize(id)
      super("Could not find document with id: #{id.inspect}")
    end
  end

  class UndefinedLock < Error
    def initialize(klass, name)
      super("Undefined lock :#{name} for class #{klass.name}")
    end
  end

  class AdapterNoLocky < Error
    def initialize(adapter)
      super("#{adapter.name.to_s.capitalize} adapter does not support locking")
    end
  end

  class InvalidKeyFactory < Error
    def initialize(name_or_factory)
      super("#{name_or_factory.inspect} is not a valid name and did not respond to next_key and key_type")
    end
  end

  class InvalidKey < Error
    def initialize(*)
      super("Key may not be nil")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
toystore-0.6.3 lib/toy/exceptions.rb
toystore-0.6.2 lib/toy/exceptions.rb