A platform for community discussion. Free, open, simple.
FIX: improve error handling for missing maxmind dbs
Sam31ad7a60abdf
diff --git a/lib/discourse_ip_info.rb b/lib/discourse_ip_info.rbindex facc0b115d6..751b48c8acc 100644--- a/lib/discourse_ip_info.rb+++ b/lib/discourse_ip_info.rb@@ -18,9 +18,11 @@ class DiscourseIpInfobeginMaxMindDB.new(filepath, MaxMindDB::LOW_MEMORY_FILE_READER)rescue Errno::ENOENT => e- Rails.logger.warn("MaxMindDB could not be found: #{e}")- rescue- Rails.logger.warn("MaxMindDB could not be loaded.")+ Rails.logger.warn("MaxMindDB (#{filepath}) could not be found: #{e}")+ nil+ rescue => e+ Discourse.warn_exception(e, "MaxMindDB (#{filepath}) could not be loaded.")+ nilendend@@ -39,8 +41,8 @@ class DiscourseIpInforet[:longitude] = result.location.longituderet[:location] = [ret[:city], ret[:region], ret[:country]].reject(&:blank?).join(", ")end- rescue- Rails.logger.error("IP #{ip} could not be looked up in MaxMind GeoLite2-City database.")+ rescue => e+ Discourse.warn_exception(e, "IP #{ip} could not be looked up in MaxMind GeoLite2-City database.")endend@@ -52,8 +54,8 @@ class DiscourseIpInforet[:asn] = result["autonomous_system_number"]ret[:organization] = result["autonomous_system_organization"]end- rescue- Rails.logger.error("IP #{ip} could not be looked up in MaxMind GeoLite2-ASN database.")+ rescue => e+ Discourse.warn_exception(e, "IP #{ip} could not be looked up in MaxMind GeoLite2-ASN database.")endend