Exception: Rubysierung::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rubysierung/error.rb

Direct Known Subclasses

Standard, Strict

Defined Under Namespace

Classes: Standard, Strict

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_data) ⇒ void

Parameters:

  • error_data (Hash<..>)

    look at message what is needed



5
6
7
# File 'lib/rubysierung/error.rb', line 5

def initialize(error_data)
  @error_data = error_data
end

Class Method Details

.set_data(_self:, name:, method_object:, file:, line:) ⇒ void

This method returns an undefined value.

sets @__error_data on provided obj pointer

Parameters:

  • _self (self)
  • name (Symbol)
  • method_object (?)
  • file (String)
  • line (Int)


32
33
34
35
36
37
38
39
# File 'lib/rubysierung/error.rb', line 32

def self.set_data(_self:, name:, method_object:, file:, line:)
  err_data = _self.instance_variable_get :@__error_data
  err_data[:method_object] = method_object
  err_data[:method_file]   = file
  err_data[:method_name]   = name
  err_data[:method_line]   = line
  _self.instance_variable_set :@__error_data, err_data
end

Instance Method Details

#messageString

TODO:

refactor into idependend methods and assemble them inside message

Returns error message.

Returns:

  • (String)

    error message



21
22
23
# File 'lib/rubysierung/error.rb', line 21

def message
  "Class:#{@error_data[:klass]}, Conversion Method:#{@error_data[:type]}, Method:#{@error_data[:method_object]}:#{@error_data[:method_file]} #{@error_data[:method_name]}:#{@error_data[:method_line]} -- called on #{@error_data[:caller]} with #{@error_data[:var_sym]}:#{@error_data[:value]} of #{@error_data[:value_class]} doesn't respond to #{@error_data[:type]}"
end

#raise_child(strict) ⇒ Rubysierung::Error::Standard|Rubysierung::Error::Strict

Returns instance of one of the two classes.

Parameters:

  • strict (Int)

    0 or 1, 1 if it strict

Returns:



11
12
13
14
15
16
17
# File 'lib/rubysierung/error.rb', line 11

def raise_child(strict)
  if strict == 0
    Rubysierung::Error::Standard.new(@error_data)
  else
    Rubysierung::Error::Strict.new(@error_data)
  end
end