Exception: Spider::Model::FormatError

Inherits:
FormatError show all
Defined in:
lib/spiderfw/model/model.rb

Overview

 Error raised when data can’t be accepted.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element, value, message) ⇒ FormatError

Takes an Element, the value, and a message. The message should be a format specification; it will be %‘d with the value.

error = FormatError.new(my_element, 3, "Element value %s is wrong.")
error.to_s  => "Element value 3 is wrong."

Parameters:



347
348
349
350
351
352
# File 'lib/spiderfw/model/model.rb', line 347

def initialize(element, value, message)
    @element = element
    @message = message
    @value = value
    super(message)
end

Instance Attribute Details

#elementElement (readonly)

Returns:



336
337
338
# File 'lib/spiderfw/model/model.rb', line 336

def element
  @element
end

#valueObject (readonly)

Returns:



338
339
340
# File 'lib/spiderfw/model/model.rb', line 338

def value
  @value
end

Instance Method Details

#to_sObject



355
356
357
358
359
360
# File 'lib/spiderfw/model/model.rb', line 355

def to_s
    label = @element.label
    Spider::GetText.in_domain('spider'){
        _(@message) % label
    }
end