Handle errors more gracefully.
authorWard Vandewege <ward@clinicalfuture.com>
Wed, 20 Mar 2013 01:38:48 +0000 (21:38 -0400)
committerWard Vandewege <ward@clinicalfuture.com>
Wed, 20 Mar 2013 01:38:48 +0000 (21:38 -0400)
cli/wh

diff --git a/cli/wh b/cli/wh
index aff797758e788f3387b501997173b578f165c100..c2538b1f71bb838213069e1119ab835eda87dfa1 100755 (executable)
--- a/cli/wh
+++ b/cli/wh
@@ -157,7 +157,9 @@ m_o = method_opts.reject {|key,value| key =~ /_given$|^json$|^jsonhuman$|^help$/
 result = client.execute :api_method => eval(api_method), :parameters => { :api_token => ENV['ORVOS_API_TOKEN'] }.merge(m_o), :authenticated => false
 results = JSON.parse result.body
 
-if method == 'list' then
+if results["errors"] then
+  abort "Error: #{results["errors"][0]}"
+elsif method == 'list' then
   results['items'].each do |i|
     if method_opts[:json] then
       puts i.to_s