Exception: BabySMS::FailedDelivery

Inherits:
Error
  • Object
show all
Defined in:
lib/babysms/errors.rb

Overview

A FailedDelivery being raised means your message didn’t get sent. This can be because of a single error, or multiple failed attempts.

A FailedDelivery may contain multiple “sub-exceptions” in #exception that can be inspected to determine what happened.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, adapter: nil) ⇒ FailedDelivery

Returns a new instance of FailedDelivery.



14
15
16
17
18
19
# File 'lib/babysms/errors.rb', line 14

def initialize(*args, adapter: nil)
  super(*args)

  @adapter = adapter
  @exceptions = [self]
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



12
13
14
# File 'lib/babysms/errors.rb', line 12

def adapter
  @adapter
end

#exceptionsObject (readonly)

Returns the value of attribute exceptions.



11
12
13
# File 'lib/babysms/errors.rb', line 11

def exceptions
  @exceptions
end

Class Method Details

.multiple(exceptions) ⇒ Object



21
22
23
24
25
26
# File 'lib/babysms/errors.rb', line 21

def self.multiple(exceptions)
  # We don't want to give a public interface to setting exceptions
  BabySMS::FailedDelivery.new("multiple exceptions").itself do |result|
    result.instance_variable_set(:@exceptions, exceptions)
  end
end

Instance Method Details

#multiple?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/babysms/errors.rb', line 28

def multiple?
  exceptions.size > 1
end