Class: Dtf::ErrorSystem

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

Overview

Dtf::ErrorSystem is DTF’s custom error management class

Class Method Summary collapse

Class Method Details

.display_errors(obj) ⇒ Object

Reusable object error display method.

Takes an Object as arg and displays that Object’s full error messages. Will return the @user object’s full error messages, 1 per line.

Example usage: Dtf::ErrorSystem.display_errors(@user)



214
215
216
217
218
219
220
# File 'lib/dtf.rb', line 214

def self.display_errors(obj)
  # TODO: Refactor error display to take sub-command as an arg
  # and display obj.errors.full_messages.each properly for each arg type.
  obj.errors.full_messages.all.each do |msg|
    $stderr.puts "#{msg}"
  end
end

.raise_error(cmd) ⇒ Object

Reusable error raising and response method. Returns exit status code of ‘1’ via abort().



202
203
204
205
206
# File 'lib/dtf.rb', line 202

def self.raise_error(cmd)
  $stderr.puts "ERROR! #{cmd} did not receive all required options."
  $stderr.puts "Please execute \'dtf #{cmd} -h\' for more information."
  abort()
end