Run a block of Ruby code, and ignore any exceptions: try { Resolv.getaddress(readline) }