Exception: BrainzLab::NotFoundError

Inherits:
Error
  • Object
show all
Defined in:
lib/brainzlab/errors.rb

Overview

Raised when a requested resource is not found.

Examples:

Resource not found

raise BrainzLab::NotFoundError.new(
  "Secret 'database_url' not found",
  hint: "Verify the secret name and environment",
  code: "secret_not_found"
)

Constant Summary

Constants inherited from Error

Error::DOCS_BASE_URL

Instance Attribute Summary collapse

Attributes inherited from Error

#code, #context, #docs_url, #hint

Instance Method Summary collapse

Methods inherited from Error

#as_json, #detailed_message, #inspect, #to_h, #to_s

Constructor Details

#initialize(message = nil, hint: nil, docs_url: nil, code: nil, context: nil, resource_type: nil, resource_id: nil) ⇒ NotFoundError

Returns a new instance of NotFoundError.



251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/brainzlab/errors.rb', line 251

def initialize(message = nil, hint: nil, docs_url: nil, code: nil, context: nil, resource_type: nil, resource_id: nil)
  @resource_type = resource_type
  @resource_id = resource_id

  code ||= 'not_found'

  context ||= {}
  context[:resource_type] = resource_type if resource_type
  context[:resource_id] = resource_id if resource_id

  super(message, hint: hint, docs_url: docs_url, code: code, context: context.empty? ? nil : context)
end

Instance Attribute Details

#resource_idString? (readonly)

Returns The identifier of the resource that was not found.

Returns:

  • (String, nil)

    The identifier of the resource that was not found



249
250
251
# File 'lib/brainzlab/errors.rb', line 249

def resource_id
  @resource_id
end

#resource_typeString? (readonly)

Returns The type of resource that was not found.

Returns:

  • (String, nil)

    The type of resource that was not found



246
247
248
# File 'lib/brainzlab/errors.rb', line 246

def resource_type
  @resource_type
end