Sha256: 503726cf622afb4a9365812611284865abf478f72f8251b6ee63b72e6c45cb6c

Contents?: true

Size: 532 Bytes

Versions: 2

Compression:

Stored size: 532 Bytes

Contents

module HttpError
  module Response
    extend ActiveSupport::Concern

    included do
      rescue_from HttpError::Error do |error|
        Rails.logger.debug "Rescuing from #{error.class}. Status: #{error.status}. Message: #{error.message}"
        render_error error
      end

      private

        def render_error(error)
          hash = {
            error: error.message,
          }

          render \
            text: error.message,
            json: hash,
            status: error.status
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
http-errors-0.1.3 lib/http_error/response.rb
http-errors-0.1.1 lib/http_error/response.rb