lib/webtopay/exception.rb in webtopay-1.2.1 vs lib/webtopay/exception.rb in webtopay-1.6.0
- old
+ new
@@ -1,7 +1,7 @@
module WebToPay
- class Exception < ::Exception
+ class Exception < ::StandardError
# Missing field.
E_MISSING = 1
# Invalid field value.
E_INVALID = 2
@@ -20,7 +20,17 @@
# SMS answer errors
E_SMS_ANSWER = 7
attr_accessor :code, :field_name
+
+ def as_json(options = {})
+ {
+ error: {
+ message: message,
+ field_name: field_name,
+ code: code
+ }
+ }
+ end
end
end