Class: Message::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/source_press/message.rb

Overview

Outputs errors to the command line

Class Method Summary collapse

Class Method Details

.error_puts(message, errors = nil) ⇒ Object

Print error message



20
21
22
23
24
25
# File 'lib/source_press/message.rb', line 20

def self.error_puts(message, errors = nil)
  puts "\nError: #{message}"
  errors&.each { |e| puts " - " << e }

  exit # Fatal error, exit program
end

.no_file(type, file, extra = "") ⇒ Object



14
15
16
17
# File 'lib/source_press/message.rb', line 14

def self.no_file(type, file, extra = "")
  msg = "Could not load #{type} file, #{file}"
  error_puts(msg << "\n       " << extra)
end

.no_files(errors = nil) ⇒ Object



9
10
11
12
# File 'lib/source_press/message.rb', line 9

def self.no_files(errors = nil)
  msg = "Could not load file(s):"
  error_puts(msg, errors)
end