lib/rpush/daemon/delivery_error.rb in rpush-1.0.0-java vs lib/rpush/daemon/delivery_error.rb in rpush-2.0.0.beta1
- old
+ new
@@ -1,8 +1,8 @@
module Rpush
class DeliveryError < StandardError
- attr_reader :code, :description
+ attr_reader :code, :notification_id
def initialize(code, notification_id, description)
@code = code
@notification_id = notification_id
@description = description
@@ -11,9 +11,17 @@
def to_s
message
end
def message
- "Unable to deliver notification #{@notification_id}, received error #{@code} (#{@description})"
+ error_str = [@code, "(#{@description})"].compact.join(' ')
+ "Unable to deliver notification #{@notification_id}, received error #{error_str}"
+ end
+
+ def ==(other)
+ other.is_a?(DeliveryError) && \
+ other.code == code && \
+ other.notification_id == notification_id && \
+ other.to_s == to_s
end
end
end