::Errno::EPIPE and ::Timeout::Error are already rescued by send_request_cgi, so I guess you don't need to handle it here. Indeed I think you need to check against nil if you want to catch the timeouts.