Sha256: c3a3ce8dd3432ddc2a5a69d81d2eb0b190112de40da2d911c4c6fcc9b626b604

Contents?: true

Size: 923 Bytes

Versions: 5

Compression:

Stored size: 923 Bytes

Contents

# Top-level class for all REST Framework errors.
class RESTFramework::Error < StandardError
end


class RESTFramework::NilPassedToAPIResponseError < RESTFramework::Error
  def message
    return <<~MSG.split("\n").join(' ')
      Payload of `nil` was passed to `api_response`; this is unsupported. If you want a blank
      response, pass `''` (an empty string) as the payload. If this was the result of a `find_by`
      (or similar Active Record method) not finding a record, you should use the bang version (e.g.,
      `find_by!`) to raise `ActiveRecord::RecordNotFound`, which the REST controller will catch and
      return an appropriate error response.
    MSG
  end
end


class RESTFramework::UnserializableError < RESTFramework::Error
  def initialize(object)
    @object = object
    return super
  end

  def message
    return "Unable to serialize `#{@object.inspect}` (of type `#{@object.class}`)."
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rest_framework-0.3.5 lib/rest_framework/errors.rb
rest_framework-0.3.4 lib/rest_framework/errors.rb
rest_framework-0.3.3 lib/rest_framework/errors.rb
rest_framework-0.3.2 lib/rest_framework/errors.rb
rest_framework-0.3.0 lib/rest_framework/errors.rb