Exception: Brut::Framework::Errors::NotFound

Inherits:
Brut::Framework::Error show all
Defined in:
lib/brut/framework/errors/not_found.rb

Overview

Indicates that a resource or database row does not exist.

Instance Method Summary collapse

Constructor Details

#initialize(resource_name:, id: nil, search_terms: nil, context: nil) ⇒ NotFound

id is present.

Parameters:

  • resource_name (String)

    Name of the type of resource

  • id (String|Int) (defaults to: nil)

    Identifier of the resource. If present, search_terms is ignored.

  • search_terms (Object) (defaults to: nil)

    If provided, these are the search terms used. Will be converted to a string via inspect. Ignored if

  • context (String) (defaults to: nil)

    Any additional context about what went wrong



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/brut/framework/errors/not_found.rb', line 8

def initialize(resource_name:,id: nil, search_terms: nil,context:nil)
  if !context.nil?
    context = ": #{context}"
  end
  fragment = if id.nil?
               "Search '#{search_terms.inspect}'"
             else
               "ID '#{id}'"
             end
  super("Could not find a #{resource_name} using #{fragment}#{context}")
end