Exception: Postini::RemoteException

Inherits:
Error
  • Object
show all
Defined in:
lib/postini/exceptions.rb

Overview

Handle exceptions thrown by Postini

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason) ⇒ RemoteException

Returns a new instance of RemoteException.



35
36
37
38
39
40
41
42
43
44
# File 'lib/postini/exceptions.rb', line 35

def initialize( reason )

  if reason =~ /^(\w+):(.*)\(Request ID ([0-9A-F\-]{36})\)$/
    @type = $1
    @message = $2.strip
    @request_id = $3
  else
    @message = reason
  end
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



16
17
18
# File 'lib/postini/exceptions.rb', line 16

def message
  @message
end

#request_idObject (readonly)

Returns the value of attribute request_id.



16
17
18
# File 'lib/postini/exceptions.rb', line 16

def request_id
  @request_id
end

#typeObject (readonly)

Returns the value of attribute type.



16
17
18
# File 'lib/postini/exceptions.rb', line 16

def type
  @type
end

Class Method Details

.delegate(reason) ⇒ Object

Find the correct sub-class and pass the exception on



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/postini/exceptions.rb', line 21

def delegate( reason )
  if reason =~ /^(\w+):/
    type = $1
    type << 'Exception' unless type =~ /Exception$/

    if Postini.const_defined?( type )
      return Postini.const_get( type ).new( reason )
    end
  end

  return new( reason )
end

Instance Method Details

#inspectObject



46
47
48
# File 'lib/postini/exceptions.rb', line 46

def inspect
  "#{self.class} Type: #{@type}, Message: #{@message}, Request ID: #{@request_id}"
end

#to_sObject



50
51
52
# File 'lib/postini/exceptions.rb', line 50

def to_s
  inspect
end