diff --git a/lib/razorpay/request.rb b/lib/razorpay/request.rb index e33ed8d..df82654 100644 --- a/lib/razorpay/request.rb +++ b/lib/razorpay/request.rb @@ -129,6 +129,9 @@ def raise_error(error, status) klass = Razorpay.const_get(class_name) raise klass.new(*args), error['description'] rescue NameError, LoadError + if !error.nil? && error.key?('description') + raise Razorpay::Error.new, error['description'] + end # We got an unknown error, cast it to Error for now raise Razorpay::Error.new, 'Unknown Error' end