Class: Ayadn::Errors

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

Class Method Summary collapse

Class Method Details

.error(status) ⇒ Object



23
24
25
# File 'lib/ayadn/errors.rb', line 23

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
# File 'lib/ayadn/errors.rb', line 5

def self.global_error(args)
  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.debug "STACK: #{args[:caller]}"
  Logs.rec.error "--END--"
  puts "\nError logged in #{Settings.config[:paths][:log]}/ayadn.log\n".color(:blue)
  Debug.err(args[:error], stack)
  exit
end

.info(msg) ⇒ Object



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

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

.no_data(where) ⇒ Object



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

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

.nr(msg) ⇒ Object



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

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

.repost(repost, original) ⇒ Object



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

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

.warn(warning) ⇒ Object



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

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

.whine(status, resp) ⇒ Object



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

def self.whine(status, resp)
  puts status
  self.error("#{status} => #{resp['meta']}")
end