Exception: StoreKit::ValidationError
- Defined in:
- lib/storekit/error.rb
Direct Known Subclasses
InvalidJsonError, InvalidReceiptFormatError, InvalidSharedSecretError, ProductionEnvironmentRequiredError, ReceiptAuthenticationError, ReceiptServerUnavailableError, SubscriptionExpiredError, TestEnvironmentRequiredError
Instance Attribute Summary collapse
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status_code) ⇒ ValidationError
constructor
A new instance of ValidationError.
- #server_error? ⇒ Boolean
Constructor Details
#initialize(status_code) ⇒ ValidationError
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/storekit/error.rb', line 8 def initialize(status_code) @status_code = status_code = case status_code when 21000 then 'The App Store could not read the JSON object you provided.' when 21002 then 'The data in the receipt-data property was malformed or missing.' when 21003 then 'The receipt could not be authenticated.' when 21004 then 'The shared secret you provided does not match the shared secret on file for your account.' when 21005 then 'The receipt server is not currently available.' when 21006 then 'This receipt is valid but the subscription has expired.' when 21007 then 'This receipt is from the test environment, but it was sent to the production environment for verification.' when 21008 then 'This receipt is from the production environment, but it was sent to the test environment for verification.' else 'Unknown error' end super() end |
Instance Attribute Details
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
6 7 8 |
# File 'lib/storekit/error.rb', line 6 def status_code @status_code end |
Class Method Details
.new(status_code) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/storekit/error.rb', line 29 def self.new status_code return super if self != ValidationError type = case status_code when 21000 then InvalidJsonError when 21002 then InvalidReceiptFormatError when 21003 then ReceiptAuthenticationError when 21004 then InvalidSharedSecretError when 21005 then ReceiptServerUnavailableError when 21006 then SubscriptionExpiredError when 21007 then TestEnvironmentRequiredError when 21008 then ProductionEnvironmentRequiredError end type.is_a?(NilClass) && super || type.new(status_code) end |
Instance Method Details
#server_error? ⇒ Boolean
25 26 27 |
# File 'lib/storekit/error.rb', line 25 def server_error? [21004, 21007, 21008].include?(status_code) || == 'Unknown error' end |