Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Commit

Permalink
Initializing APNSError from code
Browse files Browse the repository at this point in the history
Adding code attr_reader to APNSError
  • Loading branch information
mattt committed Aug 13, 2014
1 parent 92ad25a commit e6bba76
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/houston/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ class APNSError < RuntimeError
10 => "Shutdown",
255 => "Unknown error"
}

attr_reader :code

def initialize(code)
raise ArgumentError unless CODES.include?(code)
super(CODES[code])
@code = code
end
end

MAXIMUM_PAYLOAD_SIZE = 2048
Expand Down Expand Up @@ -81,7 +89,7 @@ def valid?
end

def error
APNSError.new(APNSError::CODES[@apns_error_code]) if @apns_error_code && @apns_error_code.nonzero?
APNSError.new(@apns_error_code) if @apns_error_code and @apns_error_code.nonzero?
end

private
Expand Down

0 comments on commit e6bba76

Please sign in to comment.