Exception: Mentor::MentorError

Inherits:
StandardError
  • Object
show all
Includes:
Colorize, Outputs
Defined in:
lib/errors/mentor_error.rb

Direct Known Subclasses

MentorNoMethodError

Class Method Summary collapse

Instance Method Summary collapse

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 included from Colorize

#colorize, #colorize_section

Class Method Details

.can_handle?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/errors/mentor_error.rb', line 11

def self.can_handle?
  Mentor.tp.raised_exception.class == RuntimeError
end

.error_classesObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/errors/mentor_error.rb', line 23

def self.error_classes
  [
    NoMethodDidYouMeanStringLiteralError,
    NoMethodDidYouMeanNumericLiteralError,
    NoMethodDidYouMeanSuggestionError,
    NoMethodForNilClassForCommonClassError,
    NoMethodForNilClassError,
    MentorNoMethodError,
    MentorError
  ]
end

.findObject



7
8
9
# File 'lib/errors/mentor_error.rb', line 7

def self.find
  error_classes.find(&:can_handle?)
end

Instance Method Details

#outputObject



15
16
17
18
19
20
21
# File 'lib/errors/mentor_error.rb', line 15

def output
  puts
  sections_formatted.each do |section|
    puts section
    puts
  end
end