X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=lib%2Frm%2Frm_runner.rb;h=114aabc355ad1c215f0b95e3cf1f20a2a626ea4d;hp=5fe2eaf933bf7d073a200f23381718ac60529b31;hb=bd2dabf89ab277fbe315b05e6dfa839afb5ce5ef;hpb=e3826d8926e11763837a591986d453e9ef5d9dec diff --git a/lib/rm/rm_runner.rb b/lib/rm/rm_runner.rb index 5fe2eaf..114aabc 100644 --- a/lib/rm/rm_runner.rb +++ b/lib/rm/rm_runner.rb @@ -1,3 +1,5 @@ +require 'common/runner' + class RmRunner include Runner @@ -8,25 +10,32 @@ class RmRunner begin account_description = plugin.describe_account(target) plugin.delete_account(target) - puts "Removed account: #{target} (#{account_description})" + report(plugin, "Removed account: #{target} (#{account_description})") + + rescue NonexistentAccountError => e + report(plugin, "Account not found: #{e.to_s}") rescue StandardError => e - puts "There was an error removing the account: #{e.to_s}" + report(plugin, "There was an error removing the account: #{e.to_s}") Kernel.exit(ExitCodes::DATABASE_ERROR) end else begin - # TODO: Delete all accounts first. domain_description = plugin.describe_domain(target) plugin.delete_domain(target) - puts "Removed domain: #{target} (#{domain_description})" + report(plugin, "Removed domain: #{target} (#{domain_description})") + + rescue NonexistentAccountError => e + # Can happen in the usernames.each... block. + report(plugin, "Account not found: #{e.to_s}") + rescue NonexistentDomainError => e + report(plugin, "Domain not found: #{e.to_s}") rescue StandardError => e - puts "There was an error removing the domain: #{e.to_s}" + report(plugin, "There was an error removing the domain: #{e.to_s}") Kernel.exit(ExitCodes::DATABASE_ERROR) end end end - # TODO: remove from postfixadmin as well. end end