Sha256: 17ce1a22d21ee8971258d4bcf1ff7608c9f651e22ff54dc3277bd5bca3be6667

Contents?: true

Size: 921 Bytes

Versions: 5

Compression:

Stored size: 921 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.2.4 lib/rest_framework/errors.rb
rest_framework-0.2.3 lib/rest_framework/errors.rb
rest_framework-0.2.2 lib/rest_framework/errors.rb
rest_framework-0.2.1 lib/rest_framework/errors.rb
rest_framework-0.2.0 lib/rest_framework/errors.rb