Sha256: 7ce742f6bdf3c5b037c2a7bb5a91545e6b950ff89e4c3e96a9b76c6a5d4ce9c9

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

# encoding: utf-8
module Ayadn
  class Errors
    def self.global_error(where, args, error)
      #elems = []
      #args.each {|arg| elems << self.detokenize(arg)} #TODO: make it work
      Logs.rec.error "--BEGIN--"
      Logs.rec.error "#{error}"
      Logs.rec.debug "LOCATION: #{where}"
      Logs.rec.debug "DATA: #{args}"
      Logs.rec.debug "STACK: #{caller}"
      Logs.rec.error "--END--"
      puts "\n(error logged in #{Settings.config[:paths][:log]}/ayadn.log)\n".color(:blue)
      Debug.err error
      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

    private

    def self.detokenize(string)
      string.dup.to_s.gsub!(/token=[a-zA-Z0-9_-]+/, "token=XXX") unless string.nil?
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ayadn-1.4.2 lib/ayadn/errors.rb
ayadn-1.4.1 lib/ayadn/errors.rb
ayadn-1.4.0 lib/ayadn/errors.rb
ayadn-1.3.2 lib/ayadn/errors.rb
ayadn-1.3.1 lib/ayadn/errors.rb
ayadn-1.3.0 lib/ayadn/errors.rb
ayadn-1.2.10 lib/ayadn/errors.rb
ayadn-1.2.9 lib/ayadn/errors.rb