I guess res could be nil (because of send_recv workings), so res should be checked against nil before trying to access error.