diff options
| author | Zack Hobson | 2011-07-13 11:01:46 -0700 | 
|---|---|---|
| committer | Zack Hobson | 2011-07-13 11:01:46 -0700 | 
| commit | 52b158e13aafb59055a3151ea5ef7325646ab1de (patch) | |
| tree | 71ad6f9dc73ba2929688c4451f46eeb381d497a0 | |
| parent | 097234859c38d2ee393073dc39001ab94d2463d6 (diff) | |
| download | hcl-52b158e13aafb59055a3151ea5ef7325646ab1de.tar.bz2 | |
Slightly friendlier error reporting
| -rw-r--r-- | lib/hcl/app.rb | 5 | ||||
| -rw-r--r-- | lib/hcl/timesheet_resource.rb | 6 | 
2 files changed, 7 insertions, 4 deletions
| diff --git a/lib/hcl/app.rb b/lib/hcl/app.rb index ec2ecd3..6d514da 100644 --- a/lib/hcl/app.rb +++ b/lib/hcl/app.rb @@ -80,8 +80,11 @@ module HCl        rescue RuntimeError => e          STDERR.puts "Error: #{e}"          exit 1 +      rescue SocketError => e +        STDERR.puts "Connection failed. (#{e.message})" +        exit 1        rescue TimesheetResource::Failure => e -        STDERR.puts "Internal failure. #{e}" +        STDERR.puts "API failure: #{e}"          exit 1        end      end diff --git a/lib/hcl/timesheet_resource.rb b/lib/hcl/timesheet_resource.rb index cb5e9bd..b9ba99a 100644 --- a/lib/hcl/timesheet_resource.rb +++ b/lib/hcl/timesheet_resource.rb @@ -1,6 +1,6 @@  module HCl    class TimesheetResource -    class Failure < Exception; end +    class Failure < StandardError; end      def self.configure opts = nil        if opts @@ -48,9 +48,9 @@ module HCl        if response.kind_of? Net::HTTPSuccess          response.body        elsif response.kind_of? Net::HTTPFound -        raise "Redirected in the request. Perhaps your ssl configuration variable is set incorrectly?" +        raise Failure, "Redirected in the request. Perhaps your ssl configuration variable is set incorrectly?"        else -        raise 'failure' +        raise Failure, "Unexpected response from the upstream API"        end      end | 
