HBASE-10533 commands.rb is giving wrong error messages on exceptions(rajeshbabu)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1587282 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
rajeshbabu 2014-04-14 18:59:32 +00:00
parent d8a76aa44d
commit 95974d97eb
1 changed files with 19 additions and 5 deletions

View File

@ -95,14 +95,28 @@ module Shell
# Get the special java exception which will be handled # Get the special java exception which will be handled
cause = e.cause cause = e.cause
if cause.kind_of?(org.apache.hadoop.hbase.TableNotFoundException) then if cause.kind_of?(org.apache.hadoop.hbase.TableNotFoundException) then
raise "Unknown table #{args.first}!" str = java.lang.String.new("#{cause}")
raise "Unknown table #{str}!"
end end
if cause.kind_of?(org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException) then if cause.kind_of?(org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException) then
valid_cols = table(args.first).get_all_columns.map { |c| c + '*' } exceptions = cause.getCauses
raise "Unknown column family! Valid column names: #{valid_cols.join(", ")}" exceptions.each do |exception|
if exception.kind_of?(org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException) then
valid_cols = table(args.first).get_all_columns.map { |c| c + '*' }
raise "Unknown column family! Valid column names: #{valid_cols.join(", ")}"
end
end
end end
if cause.kind_of?(org.apache.hadoop.hbase.TableExistsException) then if cause.kind_of?(org.apache.hadoop.hbase.TableExistsException) then
raise "Table already exists: #{args.first}!" str = java.lang.String.new("#{cause}")
strs = str.split("\n")
if strs.size > 0 then
s = strs[0].split(' ');
if(s.size > 1)
raise "Table already exists: #{s[1]}!"
end
raise "Table already exists: #{strs[0]}!"
end
end end
# To be safe, here only AccessDeniedException is considered. In future # To be safe, here only AccessDeniedException is considered. In future
# we might support more in more generic approach when possible. # we might support more in more generic approach when possible.