Sha256: d968078d5df267a0d6d3a468e59dc7e8463721f7408ac0a5f2861aa42b65aa62

Contents?: true

Size: 1.24 KB

Versions: 19

Compression:

Stored size: 1.24 KB

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::UnknownModelError < RESTFramework::Error
  def initialize(controller_class)
    super()
    @controller_class = controller_class
  end

  def message
    return <<~MSG.split("\n").join(" ")
      The model class for `#{@controller_class}` could not be determined. Any controller that
      includes `RESTFramework::BaseModelControllerMixin` (directly or indirectly) must either set
      the `model` attribute on the controller, or the model must be deducible from the controller
      name (e.g., `UsersController` could resolve to the `User` model).
    MSG
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rest_framework-0.9.8 lib/rest_framework/errors.rb
rest_framework-0.9.7 lib/rest_framework/errors.rb
rest_framework-0.9.6 lib/rest_framework/errors.rb
rest_framework-0.9.5 lib/rest_framework/errors.rb
rest_framework-0.9.4 lib/rest_framework/errors.rb
rest_framework-0.9.3 lib/rest_framework/errors.rb
rest_framework-0.9.2 lib/rest_framework/errors.rb
rest_framework-0.9.1 lib/rest_framework/errors.rb
rest_framework-0.9.0 lib/rest_framework/errors.rb
rest_framework-0.8.17 lib/rest_framework/errors.rb
rest_framework-0.8.16 lib/rest_framework/errors.rb
rest_framework-0.8.15 lib/rest_framework/errors.rb
rest_framework-0.8.14 lib/rest_framework/errors.rb
rest_framework-0.8.13 lib/rest_framework/errors.rb
rest_framework-0.8.12 lib/rest_framework/errors.rb
rest_framework-0.8.11 lib/rest_framework/errors.rb
rest_framework-0.8.10 lib/rest_framework/errors.rb
rest_framework-0.8.9 lib/rest_framework/errors.rb
rest_framework-0.8.8 lib/rest_framework/errors.rb