Exception: Common::Exceptions::RecordNotFound

Inherits:
BaseError
  • Object
show all
Defined in:
lib/common/exceptions/record_not_found.rb

Overview

Record Not Found - if no record exists having id, or resource having id does not belong to requester

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseError

#log_to_sentry?, #message, #sentry_type, #status_code

Constructor Details

#initialize(id, detail: nil) ⇒ RecordNotFound

Returns a new instance of RecordNotFound.



12
13
14
15
# File 'lib/common/exceptions/record_not_found.rb', line 12

def initialize(id, detail: nil)
  @id = id
  @detail = detail
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/common/exceptions/record_not_found.rb', line 10

def id
  @id
end

Instance Method Details

#errorsObject



17
18
19
20
# File 'lib/common/exceptions/record_not_found.rb', line 17

def errors
  detail = @detail.presence || { id: @id }
  Array(SerializableError.new(i18n_interpolated(detail:)))
end