Sha256: a275740736dc8d7d275c0e2e33b949148f7571158361207e9587c00725d1ca81

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8
module Ayadn
  class Errors

    def self.global_error(args)
      abort(Status.wtf) if Logs.nil? || Logs.rec.nil?
      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

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

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

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

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

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

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

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

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ayadn-1.8.2 lib/ayadn/errors.rb
ayadn-1.8.1 lib/ayadn/errors.rb
ayadn-1.8.0 lib/ayadn/errors.rb
ayadn-1.7.7 lib/ayadn/errors.rb
ayadn-1.7.6 lib/ayadn/errors.rb
ayadn-1.7.5 lib/ayadn/errors.rb