Class: TingYun::Agent::Transaction::Exceptions

Inherits:
Object
  • Object
show all
Defined in:
lib/ting_yun/agent/transaction/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeExceptions

Returns a new instance of Exceptions.



10
11
12
# File 'lib/ting_yun/agent/transaction/exceptions.rb', line 10

def initialize
  @exceptions = {}
end

Instance Attribute Details

#exceptionsObject

Returns the value of attribute exceptions.



7
8
9
# File 'lib/ting_yun/agent/transaction/exceptions.rb', line 7

def exceptions
  @exceptions
end

Instance Method Details

#count_errorsObject



41
42
43
# File 'lib/ting_yun/agent/transaction/exceptions.rb', line 41

def count_errors
  @count_errors ||=  errors.size
end

#errorsObject



45
46
47
# File 'lib/ting_yun/agent/transaction/exceptions.rb', line 45

def errors
  @errors ||= exceptions.select{|k,v| v[:type]==:error}
end

#errors_and_exceptionsObject



37
38
39
# File 'lib/ting_yun/agent/transaction/exceptions.rb', line 37

def errors_and_exceptions
  [count_errors, exceptions.size - count_errors]
end

#had_error?Boolean

collector error

Returns:

  • (Boolean)


33
34
35
# File 'lib/ting_yun/agent/transaction/exceptions.rb', line 33

def had_error?
  @have ||= count_errors == 0? false : true
end

#notice_error(error, options = {}) ⇒ Object

Do not call this. Invoke the class method instead.



24
25
26
27
28
29
30
# File 'lib/ting_yun/agent/transaction/exceptions.rb', line 24

def notice_error(error, options={}) # :nodoc:11
  if @exceptions[error]
    @exceptions[error].merge! options
  else
    @exceptions[error] = options
  end
end

#record_exceptions(attributes) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/ting_yun/agent/transaction/exceptions.rb', line 14

def record_exceptions(attributes)
  unless @exceptions.empty?
    @exceptions.each do |exception, options|
      options[:attributes]      = attributes
      ::TingYun::Agent.instance.error_collector.notice_error(exception, options)
    end
  end
end