HBASE-14119 Show error message instead of stack traces in hbase shell commands. (Apekshit)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/42a0b74c Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/42a0b74c Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/42a0b74c Branch: refs/heads/branch-1 Commit: 42a0b74cb2e5a4a1032baa0ab237d8745d40251c Parents: 12e7153 Author: Apekshit(Appy) Sharma <[email protected]> Authored: Mon Jul 20 15:31:25 2015 -0700 Committer: Matteo Bertozzi <[email protected]> Committed: Mon Jul 20 15:48:23 2015 -0700 ---------------------------------------------------------------------- hbase-shell/src/main/ruby/shell/commands.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/42a0b74c/hbase-shell/src/main/ruby/shell/commands.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands.rb b/hbase-shell/src/main/ruby/shell/commands.rb index 46258d8..b18063e 100644 --- a/hbase-shell/src/main/ruby/shell/commands.rb +++ b/hbase-shell/src/main/ruby/shell/commands.rb @@ -98,10 +98,11 @@ module Shell def translate_hbase_exceptions(*args) yield rescue => e + # Since exceptions will be thrown from the java code, 'e' will always be NativeException. + # Check for the original java exception and use it if present. raise e unless e.respond_to?(:cause) && e.cause != nil - - # Get the special java exception which will be handled cause = e.cause + # let individual command handle exceptions first if self.respond_to?(:handle_exceptions) self.handle_exceptions(cause, *args) @@ -110,6 +111,15 @@ module Shell if cause.kind_of?(org.apache.hadoop.hbase.TableNotFoundException) then raise "Unknown table #{args.first}!" end + if cause.kind_of?(org.apache.hadoop.hbase.UnknownRegionException) then + raise "Unknown region #{args.first}!" + end + if cause.kind_of?(org.apache.hadoop.hbase.NamespaceNotFoundException) then + raise "Unknown namespace #{args.first}!" + end + if cause.kind_of?(org.apache.hadoop.hbase.snapshot.SnapshotDoesNotExistException) then + raise "Unknown snapshot #{args.first}!" + end if cause.kind_of?(org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException) then exceptions = cause.getCauses exceptions.each do |exception|
