Class: Rumx::Beans::Error
- Inherits:
-
Object
- Object
- Rumx::Beans::Error
show all
- Includes:
- Rumx::Bean
- Defined in:
- lib/rumx/beans/error.rb
Instance Method Summary
collapse
Methods included from Rumx::Bean
add_root, #bean_add_child, #bean_children, #bean_each, #bean_each_child, #bean_each_child_recursive, #bean_each_embedded_child, #bean_each_operation, #bean_each_operation_recursive, #bean_embedded, #bean_find, #bean_get_and_set_attributes, #bean_get_attributes, #bean_has_attributes?, #bean_has_operations?, #bean_monitor, #bean_remove_child, #bean_set_and_get_attributes, #bean_set_attributes, #bean_synchronize, find, find_operation, included, remove_root, root
Constructor Details
#initialize(opts = {}) ⇒ Error
Returns a new instance of Error.
11
12
13
14
|
# File 'lib/rumx/beans/error.rb', line 11
def initialize(opts={})
@errors = []
@max_errors = (opts[:max_errors] || 1).to_i
end
|
Instance Method Details
#add_exception(exception) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/rumx/beans/error.rb', line 36
def add_exception(exception)
bean_synchronize do
@error_count += 1
@errors << Message.new(exception.message)
@errors.shift while @errors.size > @max_errors
end
end
|
#max_errors=(max_errors) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/rumx/beans/error.rb', line 22
def max_errors=(max_errors)
bean_synchronize do
@max_errors = max_errors
@errors.shift while @errors.size > @max_errors
end
end
|
29
30
31
32
33
34
|
# File 'lib/rumx/beans/error.rb', line 29
def perform(prefix='')
yield
rescue Exception => e
add_exception(e)
raise
end
|
#reset=(val) ⇒ Object
16
17
18
19
20
|
# File 'lib/rumx/beans/error.rb', line 16
def reset=(val)
if val
@error_count = 0
end
end
|
#to_s ⇒ Object
44
45
46
|
# File 'lib/rumx/beans/error.rb', line 44
def to_s
"error_count=#{@error_count} last_error=#{@errors.last}"
end
|