class PactBroker::DB::LogQuietener

Public Instance Methods

error(*args) click to toggle source
# File lib/pact_broker/db/log_quietener.rb, line 12
def error *args
  if error_is_about_table_not_existing?(args)
    __getobj__().debug(*reassure_people_that_this_is_expected(args))
  elsif foreign_key_error?(args)
    __getobj__().warn(*args)
  else
    __getobj__().error(*args)
  end
end
error_is_about_table_not_existing?(args) click to toggle source
# File lib/pact_broker/db/log_quietener.rb, line 22
def error_is_about_table_not_existing?(args)
  args.first.is_a?(String) &&
    ( args.first.include?("PG::UndefinedTable") ||
      args.first.include?("no such table") ||
      args.first.include?("no such view"))
end
foreign_key_error?(args) click to toggle source

Foreign key exceptions are almost always transitory and unreproducible by this stage

# File lib/pact_broker/db/log_quietener.rb, line 30
def foreign_key_error?(args)
  args.first.is_a?(String) && args.first.downcase.include?("foreign key")
end
reassure_people_that_this_is_expected(args) click to toggle source
# File lib/pact_broker/db/log_quietener.rb, line 34
def reassure_people_that_this_is_expected(args)
  message = args.shift
  message = message + " Don't panic. This happens when Sequel doesn't know if a table/view exists or not."
  [message] + args
end