class Noise::ErrorSerializer

Generic error serializer

Constants

BUGSNAG_URL

Public Instance Methods

attributes(*) click to toggle source
Calls superclass method
# File lib/noise/error_serializer.rb, line 19
def attributes(*)
  data = super
  data['object'] = 'error'
  data
end
code() click to toggle source
# File lib/noise/error_serializer.rb, line 29
def code
  code_from_http_status
end
fallback_message() click to toggle source
# File lib/noise/error_serializer.rb, line 45
def fallback_message
  nil
end
id() click to toggle source
# File lib/noise/error_serializer.rb, line 25
def id
  scope.try(:[], :id)
end
title() click to toggle source
# File lib/noise/error_serializer.rb, line 33
def title
  'Internal Server Error'
end

Private Instance Methods

bugsnag_search_url() click to toggle source
# File lib/noise/error_serializer.rb, line 58
def bugsnag_search_url
  return unless Noise.config.bugsnag_project
  return unless id
  require 'addressable/template'

  template = Addressable::Template.new(BUGSNAG_URL)
  template.expand(id: id, organization: Noise.config.bugsnag_organization, project: Noise.config.bugsnag_project)
end
code_from_http_status() click to toggle source
# File lib/noise/error_serializer.rb, line 51
def code_from_http_status
  http_status = scope.try(:[], :http_status).to_i
  default_message = Rack::Utils::HTTP_STATUS_CODES[500]
  status_code = Rack::Utils::HTTP_STATUS_CODES.fetch(http_status, default_message)
  status_code.parameterize.underscore.to_sym
end