Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rename to propagates_errors

  • Loading branch information...
commit 19de4ae66660139d2c2e36fd219580af5e35abda 1 parent 1c29c46
@sorah sorah authored
View
2  lib/chanko/function.rb
@@ -55,7 +55,7 @@ def invoke!(scope, options={})
end
rescue ::Exception => e
Chanko::Loader.aborted(unit.unit_name)
- Chanko::ExceptionNotifier.notify("raise exception #{unit.name}##{@label} => #{e.message}", @unit.raise_error?,
+ Chanko::ExceptionNotifier.notify("raise exception #{unit.name}##{@label} => #{e.message}", @unit.propagates_errors?,
:exception => e, :backtrace => e.backtrace[0..20], :key => "#{unit.name}_exception", :context => scope)
return Chanko::Aborted
ensure
View
2  lib/chanko/method_proxy.rb
@@ -27,7 +27,7 @@ def unit(_unit_label=nil, &block)
unit = Chanko::Loader.fetch(unit_label)
yield unit
rescue ::Exception => e
- Chanko::ExceptionNotifier.notify("unknown error #{_unit_label}", unit.raise_error?,
+ Chanko::ExceptionNotifier.notify("unknown error #{_unit_label}", unit.propagates_errors?,
:exception => e,
:key => "method_proxy unknown error #{_unit_label}",
:context => self,
View
18 lib/chanko/unit.rb
@@ -49,7 +49,7 @@ def expand(klass_name, &block)
begin
klass = klass_name.constantize
rescue NameError => e
- Chanko::ExceptionNotifier.notify("expand name error #{self.name} #{klass_name}", self.expand_owner.raise_error?,
+ Chanko::ExceptionNotifier.notify("expand name error #{self.name} #{klass_name}", self.expand_owner.propagates_errors?,
:key => "#{self.name} expand error", :exception => e,
:context => self, :backtrace => e.backtrace[0..20]
)
@@ -72,23 +72,23 @@ module ClassMethods
attr_reader :shared_methods
def active_if(*symbols, &block)
- @active_if = Chanko::ActiveIf.new(*(symbols + [:raise => @raise_error]), &block)
+ @active_if = Chanko::ActiveIf.new(*(symbols + [:raise => @propagates_errors]), &block)
end
alias_method :judge, :active_if
- def raise_error(o=true)
- @raise_error = o
+ def propagates_errors(o=true)
+ @propagates_errors = o
end
- alias_method :raise_error=, :raise_error
+ alias_method :propagates_errors=, :propagates_errors
- def raise_error?; @raise_error ||= false; end
+ def propagates_errors?; @propagates_errors ||= false; end
def active?(context=nil, options={})
begin
options = options.merge(:unit => self)
@active_if.enabled?(context, options)
rescue ::Exception => e
- Chanko::ExceptionNotifier.notify("Activeif definition #{self.name} raised", @raise_error,
+ Chanko::ExceptionNotifier.notify("Activeif definition #{self.name} raised", @propagates_errors,
:key => "#{self.name}_active?",
:context => context,
:backtrace => e.backtrace[0..20],
@@ -145,7 +145,7 @@ def scope(scope, &block)
begin
scope_klass = scope_klass_string.constantize
rescue NameError => e
- Chanko::ExceptionNotifier.notify("scope '#{scope_klass_string}' is unable to constantize", @raise_error,
+ Chanko::ExceptionNotifier.notify("scope '#{scope_klass_string}' is unable to constantize", @propagates_errors,
:key => "#{self.name} expand error", :exception => e,
:backtrace => e.backtrace[0..20])
end
@@ -302,7 +302,7 @@ def functions(context, label, active_if_options={}, options = {})
return cbks.dup unless cbks.blank?
- Chanko::ExceptionNotifier.notify("missing functions #{self.name}##{label}", @raise_error,
+ Chanko::ExceptionNotifier.notify("missing functions #{self.name}##{label}", @propagates_errors,
:exception_klass => Chanko::Exception::MissingFunction,
:key => "missing function #{self.name}",
:context => self
View
10 spec/lib/function_spec.rb
@@ -50,14 +50,14 @@ class ExceptionToNotPassThroughed < Exception; end
after(:all) { Chanko.config.propagated_errors = @config_save }
end
- describe 'with unit.raise_error' do
+ describe 'with unit.propagates_errors' do
before do
no_raise_chanko_exception
mock_unit("RaiseErrorTest")
end
- it "doesn't raise the exception when raise_error == false" do
- RaiseErrorTest.raise_error = false
+ it "doesn't raise the exception when propagates_errors == false" do
+ RaiseErrorTest.propagates_errors = false
function = Chanko::Function.new(:hello, RaiseErrorTest) do
raise Exception
end
@@ -65,8 +65,8 @@ class ExceptionToNotPassThroughed < Exception; end
expect { function.invoke!(controller) }.to_not raise_error
end
- it "raises the exception if raise_error == true" do
- RaiseErrorTest.raise_error = true
+ it "raises the exception if propagates_errors == true" do
+ RaiseErrorTest.propagates_errors = true
function = Chanko::Function.new(:hello, RaiseErrorTest) do
raise Exception
end
View
6 spec/lib/method_proxy_spec.rb
@@ -75,17 +75,17 @@ def hello; 'hello'; end
}.to_not raise_error(StandardError, 'error')
end
- it 'raise error when unit.raise_error is true' do
+ it 'raise error when unit.propagates_errors is true' do
no_raise_chanko_exception
begin
- ProxyTest.raise_error
+ ProxyTest.propagates_errors = true
expect {
receiver.unit(:proxy_test) do |unit|
raise StandardError, 'error'
end
}.to raise_error(StandardError, 'error')
ensure
- ProxyTest.raise_error = false
+ ProxyTest.propagates_errors = false
end
end
View
2  spec/lib/unit_spec.rb
@@ -234,7 +234,7 @@
before do
no_raise_chanko_exception
mock_unit("RaiseErrorTest", Chanko::Test::Invoker)
- RaiseErrorTest.raise_error = true
+ RaiseErrorTest.propagates_errors = true
end
it 'raises missingfunction' do
Please sign in to comment.
Something went wrong with that request. Please try again.