- # Why think too hard? An user has an @, a domain doesn't.
- if target.include?('@') then
- begin
- user_description = plugin.describe_user(target)
- plugin.delete_user(target)
- report(plugin, "Removed user: #{target} (#{user_description})")
-
- rescue NonexistentUserError => e
- report(plugin, "User not found: #{e.to_s}")
- rescue StandardError => e
- report(plugin, "There was an error removing the user: #{e.to_s}")
- Kernel.exit(ExitCodes::DATABASE_ERROR)
- end
- else
- begin
- domain_description = plugin.describe_domain(target)
- plugin.delete_domain(target)
- report(plugin, "Removed domain: #{target} (#{domain_description})")
-
- rescue NonexistentUserError => e
- # Can happen in the usernames.each... block.
- report(plugin, "User not found: #{e.to_s}")
- rescue NonexistentDomainError => e
- report(plugin, "Domain not found: #{e.to_s}")
- rescue StandardError => e
- report(plugin, "There was an error removing the domain: #{e.to_s}")
- Kernel.exit(ExitCodes::DATABASE_ERROR)
- end
- end