Sha256: 4e231a90f737d3374dcd85fd0b9bffe5e24db542d3d2beafe982ecd05d478f9c

Contents?: true

Size: 1.87 KB

Versions: 11

Compression:

Stored size: 1.87 KB

Contents

# TODO: Create more specific errors
#
module ActiveRemote
  # Generic Active Remote exception class.
  class ActiveRemoteError < StandardError
  end

  class DangerousAttributeError < ActiveRemoteError
  end

  # Raised by ActiveRemove::Base.save when the remote record is readonly.
  class ReadOnlyRemoteRecord < ActiveRemoteError
  end

  # Raised by ActiveRemote::Validations when save is called on an invalid record.
  class RemoteRecordInvalid < ActiveRemoteError
    attr_reader :record

    def initialize(record)
      @record = record
      errors = @record.errors.full_messages.join(', ')
      super(errors)
    end
  end

  # Raised by ActiveRemote::Base.find when remote record is not found when
  # searching with the given arguments.
  class RemoteRecordNotFound < ActiveRemoteError
    attr_accessor :remote_record_class

    def initialize(class_or_message = "")
      message = class_or_message

      if class_or_message.is_a?(Class)
        self.remote_record_class = class_or_message
        message = "#{remote_record_class} does not exist"
      end

      super(message)
    end
  end

  # Raised by ActiveRemove::Base.save! and ActiveRemote::Base.create! methods
  # when remote record cannot be saved because it is invalid.
  class RemoteRecordNotSaved < ActiveRemoteError
  end

  class UnknownAttributeError < ActiveRemoteError
  end

  # Errors from Protobuf
  class BadRequestDataError < ActiveRemoteError
  end

  class BadRequestProtoError < ActiveRemoteError
  end

  class ServiceNotFoundError < ActiveRemoteError
  end

  class MethodNotFoundError < ActiveRemoteError
  end

  class RpcError < ActiveRemoteError
  end

  class RpcFailedError < ActiveRemoteError
  end

  class InvalidRequestProtoError < ActiveRemoteError
  end

  class BadResponseProtoError < ActiveRemoteError
  end

  class UnknownHostError < ActiveRemoteError
  end

  class IOError < ActiveRemoteError
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
active_remote-3.3.1 lib/active_remote/errors.rb
active_remote-3.3.0 lib/active_remote/errors.rb
active_remote-3.2.2 lib/active_remote/errors.rb
active_remote-3.2.1 lib/active_remote/errors.rb
active_remote-3.2.0 lib/active_remote/errors.rb
active_remote-3.2.0.pre lib/active_remote/errors.rb
active_remote-3.1.3 lib/active_remote/errors.rb
active_remote-3.1.2 lib/active_remote/errors.rb
active_remote-3.1.2.pre lib/active_remote/errors.rb
active_remote-3.1.1 lib/active_remote/errors.rb
active_remote-3.1.0 lib/active_remote/errors.rb