class JsonapiErrorsHandler::Errors::StandardError

Handles serialization of Unexpected HTTP error (500 status code) It's also a fallback for not mapped errors in the application.

Attributes

detail[R]
source[R]
status[R]
title[R]

Public Class Methods

new( title: nil, status: nil, detail: nil, message: nil, source: {} ) click to toggle source
# File lib/jsonapi_errors_handler/errors/standard_error.rb, line 11
def initialize(
  title: nil, status: nil, detail: nil, message: nil, source: {}
)
  @title = title || 'Something went wrong'
  @detail = detail || message
  @detail ||= "We've encountered unexpected error, but our developers had been already notified about it" # rubocop:disable Metrics/LineLength
  @status = status || 500
  @source = KeysStringifier.call(source)
end

Public Instance Methods

serializable_hash() click to toggle source
# File lib/jsonapi_errors_handler/errors/standard_error.rb, line 21
def serializable_hash
  {
    status: status,
    title: title,
    detail: detail,
    source: source
  }
end
to_h() click to toggle source
# File lib/jsonapi_errors_handler/errors/standard_error.rb, line 30
def to_h
  serializable_hash
end
to_s() click to toggle source
# File lib/jsonapi_errors_handler/errors/standard_error.rb, line 34
def to_s
  serializable_hash.to_s
end