Exception: Mentor::NoMethodForNilClassError

Inherits:
MentorNoMethodError show all
Defined in:
lib/errors/no_method_for_nil_class_error.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Colorize

#colorize, #colorize_section

Methods included from OutputHelper

#a_an, #and_sentence, #culprit_line, #home_to_tilde, #indent_lines, #lines_from_file, #or_sentence, #pluralize, #pluralize_words, #terminal_width, #valid_var_name

Methods inherited from MentorError

error_classes, find, #output

Class Method Details

.can_handle?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/errors/no_method_for_nil_class_error.rb', line 5

def self.can_handle?
  super && Mentor.tp.raised_exception.to_s['NilClass']
end

Instance Method Details

#sectionsObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/errors/no_method_for_nil_class_error.rb', line 9

def sections
  [
    Header.new,
    RubyErrorComplete.new,
    RelativePath.new,
    LinesOfCode.new,
    ErrorClassSpecificHelp.new([error_class_specific_help]),
    Suggestion.new("Try setting #{var_for_method} to a value first and then call the method #{method_name} on it.")
  ]
end