From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id F00BE138A87 for ; Wed, 25 Feb 2015 23:54:45 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7A783E08D5; Wed, 25 Feb 2015 23:54:45 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 18637E08D5 for ; Wed, 25 Feb 2015 23:54:45 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E5547340ADD for ; Wed, 25 Feb 2015 23:54:43 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 60672128DC for ; Wed, 25 Feb 2015 23:54:42 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1424908476.face39b1a3a32f3a9a49747059dac1484025458d.robbat2@gentoo> Subject: [gentoo-commits] proj/ag:master commit in: / X-VCS-Repository: proj/ag X-VCS-Files: ag X-VCS-Directories: / X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: face39b1a3a32f3a9a49747059dac1484025458d X-VCS-Branch: master Date: Wed, 25 Feb 2015 23:54:42 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: a751bd87-02d6-44de-bf2e-a377e69e3e52 X-Archives-Hash: 8116266a18c0ec332c5207fd085d0468 commit: face39b1a3a32f3a9a49747059dac1484025458d Author: Robin H. Johnson gentoo org> AuthorDate: Wed Feb 25 23:54:36 2015 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Wed Feb 25 23:54:36 2015 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/ag.git;a=commit;h=face39b1 Improve error handling. Signed-off-by: Robin H. Johnson gentoo.org> --- ag | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ag b/ag index f3c106e..5602df5 100755 --- a/ag +++ b/ag @@ -51,14 +51,14 @@ op = OptionParser.new do |opts| $options.action = :do_delete_msg end - + opts.on('--create-index', 'Create index but do not populate. Needs --list') do abort 'Can only select one action' if $options.action != nil $options.action = :do_create_index $options.need_argument = false end - + opts.on('--rethread', 'Rethread messages. Needs --list') do abort 'Can only select one action' if $options.action != nil @@ -215,22 +215,27 @@ def do_delete_msg end end -def do_delete_index(ignore_missing: false) +def do_delete_index(ignore_missing: false, _raise: false) begin Ag::Storage.delete_index($options.name) rescue Elasticsearch::Transport::Transport::Errors::NotFound => e - $stderr.puts "Index does not exist: #{e}" unless ignore_missing + unless ignore_missing + raise e if _raise + $stderr.puts "Index does not exist: #{e}" + end rescue => e + raise e if _raise $stderr.puts "Cannot delete index: #{e}" end end -def do_create_index(ignore_exists: false) +def do_create_index(ignore_exists: false, _raise: false) begin Ag::Storage.create_index($options.name) rescue Elasticsearch::Transport::Transport::Errors::BadRequest => e - if ignore_exists and e !~ /IndexAlreadyExistsException/ - raise e + unless (ignore_exists and e.message =~ /IndexAlreadyExistsException/) + raise e if _raise + $stderr.puts "Cannot create index #{e}" end end end