Sha256: 2f3d16b9dc3c3e9c31f72a93e37c10f667f690a4184970bcc1fec355ac94a5b7

Contents?: true

Size: 860 Bytes

Versions: 6

Compression:

Stored size: 860 Bytes

Contents

# :nocov:
module DefaultHandling
  def self.included(cls)
    cls.class_eval do
      include ErrorNotifier

      # must go first in order to preserve last priority
      # https://stackoverflow.com/a/9121054/3287738
      rescue_from StandardError do |e|
        report_error(e)
        respond Commons::Errors::InternalServerError.new
      end

      rescue_from Commons::Errors::ErrorBase do |e|
        if e.instance_of?(Commons::Errors::InternalServerError) ||
           e.is_a?(Commons::Errors::InternalServerError) ||
           Rails.env.development?
          report_error(e)
        end
        respond e
      end
    end
  end

  def respond(error)
    render json: [error],
           status: error.status,
           each_serializer: Commons::Errors::ErrorSerializer
  end

  def report_error(param)
    print_trace(param)
  end
end
# :nocov:

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
commons_yellowme-0.16.0 spec/dummy/app/errors/default_handling.rb
commons_yellowme-0.15.0 spec/dummy/app/errors/default_handling.rb
commons_yellowme-0.12.0 spec/dummy/app/errors/default_handling.rb
commons_yellowme-0.11.3 spec/dummy/app/errors/default_handling.rb
commons_yellowme-0.11.2 spec/dummy/app/errors/default_handling.rb
commons_yellowme-0.11.1 spec/dummy/app/errors/default_handling.rb