Class: RescueEach::Error::Item

Inherits:
Struct
  • Object
show all
Defined in:
lib/rescue_each.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argsObject

Returns the value of attribute args

Returns:

  • (Object)

    the current value of args



15
16
17
# File 'lib/rescue_each.rb', line 15

def args
  @args
end

#exceptionObject

Returns the value of attribute exception

Returns:

  • (Object)

    the current value of exception



15
16
17
# File 'lib/rescue_each.rb', line 15

def exception
  @exception
end

Instance Method Details

#args_fullObject



34
35
36
# File 'lib/rescue_each.rb', line 34

def args_full
  "args: #{args.inspect}"
end

#args_shortObject



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

def args_short
  args_str = args.map do |arg|
    str = arg.inspect
    max_length = 500
    if str.size > max_length
      str.slice(0, max_length) + " [#{str.size-max_length} more chars...]"
    else
      str
    end
  end
  "args: " + args_str.join(", ")
end

#backtrace_linesObject



38
39
40
# File 'lib/rescue_each.rb', line 38

def backtrace_lines
  exception.backtrace.take_while { |line| !line.index(__FILE__) }
end

#backtrace_sObject



42
43
44
# File 'lib/rescue_each.rb', line 42

def backtrace_s
  "\t#{backtrace_lines.join "\n\t"}"
end

#messageObject



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

def message
  "#{title}\n#{args_full}\n#{backtrace_s}"
end

#short_messageObject



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

def short_message
  "#{title} (#{args_short})"
end

#titleObject



17
18
19
# File 'lib/rescue_each.rb', line 17

def title
  "#{exception.message} (#{exception.class})"
end

#to_sObject



54
55
56
# File 'lib/rescue_each.rb', line 54

def to_s
  "\n#{message}"
end