Class: Ayadn::Errors

Inherits:
Object show all
Defined in:
lib/ayadn/errors.rb

Class Method Summary collapse

Class Method Details

.error(status) ⇒ Object



28
29
30
# File 'lib/ayadn/errors.rb', line 28

def self.error(status)
  Logs.rec.error status
end

.global_error(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ayadn/errors.rb', line 5

def self.global_error(args)
  if Logs.nil? || Logs.rec.nil?
    Status.new.wtf
    exit
  end
  thor = Thor::Shell::Color.new
  Logs.rec.error "--BEGIN--"
  Logs.rec.error "CAUSE: #{args[:error]}"
  Logs.rec.debug "DATA: #{args[:data]}"
  stack = args[:caller].map do |path|
    splitted = path.split('/')
    file = splitted.pop
    dir = splitted.pop
    "#{dir}/#{file}"
  end
  Logs.rec.debug "STACK: #{stack}"
  Logs.rec.error "--END--"
  thor.say_status :error, "logged in #{Settings.config[:paths][:log]}/ayadn.log", :red
  puts "\n"
  Debug.err(args[:error], stack)
  exit
end

.info(msg) ⇒ Object



36
37
38
# File 'lib/ayadn/errors.rb', line 36

def self.info(msg)
  Logs.rec.info msg
end

.no_data(where) ⇒ Object



48
49
50
51
52
# File 'lib/ayadn/errors.rb', line 48

def self.no_data(where)
  self.warn "In action/#{where}: no data"
  Status.new.empty_list
  exit
end

.nr(msg) ⇒ Object



44
45
46
# File 'lib/ayadn/errors.rb', line 44

def self.nr msg
  Logs.nr.warn msg
end

.repost(repost, original) ⇒ Object



40
41
42
# File 'lib/ayadn/errors.rb', line 40

def self.repost(repost, original)
  Logs.rec.info "Post #{repost} is a repost. Using original: #{original}."
end

.warn(warning) ⇒ Object



32
33
34
# File 'lib/ayadn/errors.rb', line 32

def self.warn(warning)
  Logs.rec.warn warning
end