From e06ceb5d9f2fa5214680f71a19dfdcd7e6bb9d10 Mon Sep 17 00:00:00 2001 From: HD Moore Date: Fri, 28 Sep 2018 12:41:12 +0000 Subject: [PATCH] Don't spam errors for missing normalize, fix #1 --- bin/normalize.rb | 4 ++++ lib/inetdata/source/base.rb | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/normalize.rb b/bin/normalize.rb index bf9593f..4629796 100755 --- a/bin/normalize.rb +++ b/bin/normalize.rb @@ -78,6 +78,10 @@ sources.each do |s| begin s.normalize + rescue ::InetData::Source::Base::NotImplemented + # logger.log("Warning: Source #{s.name} does not implement normalize()") + rescue ::Interrupt + logger.log("Error: Source #{s.name} was interrupted: #{$!.class} #{$!} #{$!.backtrace}") rescue ::Exception logger.log("Error: Source #{s.name} threw an exception: #{$!.class} #{$!} #{$!.backtrace}") end diff --git a/lib/inetdata/source/base.rb b/lib/inetdata/source/base.rb index 69c568f..89e9bb5 100644 --- a/lib/inetdata/source/base.rb +++ b/lib/inetdata/source/base.rb @@ -2,6 +2,9 @@ module InetData module Source class Base + class NotImplemented < ::RuntimeError + end + @@have_inetdata_parsers = nil VALID_HOSTNAME = /^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$/ @@ -57,11 +60,11 @@ def reports_path end def download - raise RuntimeError.new, "Download not implemented for source #{self.name}" + raise NotImplemented end def normalize - raise RuntimeError.new, "Normalize not implemented for source #{self.name}" + raise NotImplemented end def validate_domain(dname)