Class: EacRubyBase0::ErrorPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_ruby_base0/error_presenter.rb

Instance Method Summary collapse

Instance Method Details

#full_backtrace_messageString

Returns:

  • (String)


9
10
11
# File 'lib/eac_ruby_base0/error_presenter.rb', line 9

def full_backtrace_message
  the_error.backtrace.map { |v| "#{v}\n" }.join
end

#full_messageString

Returns:

  • (String)


14
15
16
17
18
# File 'lib/eac_ruby_base0/error_presenter.rb', line 14

def full_message
  self_full_message + the_error.cause.if_present('') do |e|
    "#{'-' * 16}\n#{self.class.new(e).full_message}"
  end
end

#log_pathPathname

Returns:

  • (Pathname)


26
27
28
# File 'lib/eac_ruby_base0/error_presenter.rb', line 26

def log_path
  @log_path ||= ::EacRubyUtils::Fs::Temp.file.to_pathname.tap { |e| e.write(full_message) }
end

#messageString

Returns:

  • (String)


21
22
23
# File 'lib/eac_ruby_base0/error_presenter.rb', line 21

def message
  "#{the_error.message} (#{the_error.class})"
end

#self_full_messageString

Returns:

  • (String)


31
32
33
34
35
# File 'lib/eac_ruby_base0/error_presenter.rb', line 31

def self_full_message
  "Error class: #{the_error.class}\n" \
  "Message: #{the_error.message}\n" \
  "Backtrace:\n" + the_error.backtrace.map { |v| "#{v}\n" }.join
end

#showvoid

This method returns an undefined value.



38
39
40
41
# File 'lib/eac_ruby_base0/error_presenter.rb', line 38

def show
  show_message
  show_log_file
end

#show_log_filevoid

This method returns an undefined value.



49
50
51
# File 'lib/eac_ruby_base0/error_presenter.rb', line 49

def show_log_file
  infov 'Full log', log_path
end

#show_messagevoid

This method returns an undefined value.



44
45
46
# File 'lib/eac_ruby_base0/error_presenter.rb', line 44

def show_message
  error message
end