Exception: Pdfcrowd::Error

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/pdfcrowd.rb

Overview

Thrown when an error occurs.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error, http_code = nil) ⇒ Error

Returns a new instance of Error.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/pdfcrowd.rb', line 49

def initialize(error, http_code=nil)
  super()
  @error = error
  error_match = @error.match(/^(\d+)\.(\d+)\s+-\s+(.*?)(?:\s+Documentation link:\s+(.*))?$/) ||
                @error.scan(/^(\d+)\.(\d+)\s+-\s+(.*?)(?:\s+Documentation link:\s+(.*))?$/m)
  if error_match and error_match != []
      @http_code = error_match[1]
      @reason_code = error_match[2]
      @message = error_match[3]
      @doc_link = error_match[4] || ''
  else
      @http_code = http_code
      @reason_code = -1
      @message = @error
      if @http_code
          @error = "#{@http_code} - #{@error}"
      end
      @doc_link = ''
  end
end

Instance Attribute Details

Returns the value of attribute doc_link.



47
48
49
# File 'lib/pdfcrowd.rb', line 47

def doc_link
  @doc_link
end

#errorObject (readonly)

Returns the value of attribute error.



47
48
49
# File 'lib/pdfcrowd.rb', line 47

def error
  @error
end

#http_codeObject (readonly)

Returns the value of attribute http_code.



47
48
49
# File 'lib/pdfcrowd.rb', line 47

def http_code
  @http_code
end

#messageObject (readonly)

Returns the value of attribute message.



47
48
49
# File 'lib/pdfcrowd.rb', line 47

def message
  @message
end

#reason_codeObject (readonly)

Returns the value of attribute reason_code.



47
48
49
# File 'lib/pdfcrowd.rb', line 47

def reason_code
  @reason_code
end

Instance Method Details

#getCodeObject



74
75
76
77
# File 'lib/pdfcrowd.rb', line 74

def getCode()
    warn "[DEPRECATION] `getCode` is obsolete and will be removed in future versions. Use `getStatusCode` instead."
    @http_code
end


91
92
93
# File 'lib/pdfcrowd.rb', line 91

def getDocumentationLink()
    @doc_link
end

#getMessageObject



87
88
89
# File 'lib/pdfcrowd.rb', line 87

def getMessage()
    @message
end

#getReasonCodeObject



83
84
85
# File 'lib/pdfcrowd.rb', line 83

def getReasonCode()
    @reason_code
end

#getStatusCodeObject



79
80
81
# File 'lib/pdfcrowd.rb', line 79

def getStatusCode()
    @http_code
end

#to_sObject



70
71
72
# File 'lib/pdfcrowd.rb', line 70

def to_s()
    @error
end