Permalink
Browse files

Handle unforeseen errors more robustly

  • Loading branch information...
1 parent c98a68d commit 22304e44eb2da356305e2ad7a5c0572431693cf7 @purcell committed Aug 31, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 bin/postfix-policy-whois
View
@@ -60,10 +60,16 @@ while true
end
sender = attr["sender"]
- dodgy = sender && dodgy?(sender.scan(/@(.*)/).flatten.first.downcase)
+ dodgy = false
- if dodgy
- $LOG.log(Syslog::LOG_NOTICE, "Rejecting mail due to registrar: #{sender}")
+ begin
+ $LOG.log(Syslog::LOG_INFO, "Checking sender: #{sender}")
+ dodgy = dodgy?(sender.scan(/@(.*)/).flatten.first.downcase)
+ if dodgy
+ $LOG.log(Syslog::LOG_NOTICE, "Rejecting mail due to registrar: #{sender}")
+ end
+ rescue
+ $LOG.log(Syslog::LOG_ERR, "Error checking registrar: #{$!}")
end
client.write("action=" + (dodgy ? "REJECT" : "DUNNO") + "\n")

0 comments on commit 22304e4

Please sign in to comment.