Skip to content

Commit b61e412

Browse files
author
Ross Crawford-d'Heureuse
committed
1. Added to_s to adcloudapi exception so that we can just output ex and not ex.message (seems to be what everyone is doing and will help with debugging)
2. Added better exception handling.. in the else case the api was simply returning a standard error with the response.status.. which is pretty useless in some cases (ssl,timeouts,etc) so now it throws ab UnknownError that acts in the standard adcloud manner
1 parent ed4f5bd commit b61e412

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

lib/adcloud.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module Adcloud
3333
autoload :WebhookEvent, "adcloud/webhook_event"
3434

3535
module AdcloudUnknownAPIError; class InvalidApiResponse < StandardError; end; end
36+
class UnknownError < ApiError; end
3637
class BadRequestError < ApiError; end
3738
class NotFoundError < ApiError; end
3839
class ServerError < ApiError; end

lib/adcloud/api_error.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ def status
2828
self.meta["status"]
2929
end
3030

31+
def to_s
32+
self.response.message
33+
end
34+
3135
end
3236

3337
end

lib/adcloud/exception_raiser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def initialize(response)
1515
when 500
1616
raise Adcloud::ServerError.new(response)
1717
else
18-
raise StandardError.new("Could not handle status #{response.status}")
18+
raise Adcloud::UnknownError.new(response)
1919
end
2020
end
2121

0 commit comments

Comments
 (0)