Exception: ImportException

Inherits:
StandardError
  • Object
show all
Defined in:
backend/app/lib/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ ImportException

Returns a new instance of ImportException.



91
92
93
94
# File 'backend/app/lib/exceptions.rb', line 91

def initialize(opts)
  @invalid_object = opts[:invalid_object]
  @error = opts[:error]
end

Instance Attribute Details

#errorObject

Returns the value of attribute error



89
90
91
# File 'backend/app/lib/exceptions.rb', line 89

def error
  @error
end

#invalid_objectObject

Returns the value of attribute invalid_object



87
88
89
# File 'backend/app/lib/exceptions.rb', line 87

def invalid_object
  @invalid_object
end

#messageObject

Returns the value of attribute message



88
89
90
# File 'backend/app/lib/exceptions.rb', line 88

def message
  @message
end

Instance Method Details

#to_hashObject



96
97
98
99
100
101
102
103
104
105
106
107
# File 'backend/app/lib/exceptions.rb', line 96

def to_hash
  hsh = {'record_title' => nil, 'record_type' => nil, 'error_class' => self.class.name, 'errors' => []}
  hsh['record_title'] = @invalid_object[:title] ? @invalid_object[:title] : "unknown or untitled"
  hsh['record_type'] = @invalid_object.jsonmodel_type ? @invalid_object.jsonmodel_type : "unknown type"

  if @error.respond_to?(:errors)
    @error.errors.each {|e| hsh['errors'] << e}
  else
    hsh['errors'] = @error.inspect
  end
  hsh
end

#to_sObject



109
110
111
# File 'backend/app/lib/exceptions.rb', line 109

def to_s
  "#<:ImportException: #{{:invalid_object => @invalid_object, :error => @error}.inspect}>"
end