From d7ad5598a35aa242d7049a4ddccdda5036e1ee87 Mon Sep 17 00:00:00 2001 From: Ildar Kayumov Date: Thu, 3 Mar 2016 16:29:17 +0300 Subject: [PATCH] Add Exceptions: AccessDenied, RequestThrottled, InvalidParameterValue --- lib/ruby-mws/api/response.rb | 8 +++++--- lib/ruby-mws/exceptions.rb | 14 +++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/ruby-mws/api/response.rb b/lib/ruby-mws/api/response.rb index fef0bb1..4817b91 100644 --- a/lib/ruby-mws/api/response.rb +++ b/lib/ruby-mws/api/response.rb @@ -34,10 +34,12 @@ def self.parse(hash, name, params) def self.handle_error_response(error) msg = "#{error.code}: #{error.message}" msg << " -- #{error.detail}" unless error.detail.nil? - raise ErrorResponse, msg + if MWS.const_defined? error.code + raise "MWS::#{error.code}".constantize, msg + else + raise ErrorResponse, msg + end end - end - end end diff --git a/lib/ruby-mws/exceptions.rb b/lib/ruby-mws/exceptions.rb index 654fe76..94c3f6e 100644 --- a/lib/ruby-mws/exceptions.rb +++ b/lib/ruby-mws/exceptions.rb @@ -1,5 +1,4 @@ module MWS - class MWSException < StandardError end @@ -9,9 +8,18 @@ class MissingConnectionOptions < MWSException class NoNextToken < MWSException end + class BadResponseError < MWSException + end + class ErrorResponse < MWSException end - class BadResponseError < MWSException + class AccessDenied < ErrorResponse + end + + class RequestThrottled < ErrorResponse + end + + class InvalidParameterValue < ErrorResponse end -end \ No newline at end of file +end