Skip to content

Commit

Permalink
Handle error being set to a raw string
Browse files Browse the repository at this point in the history
* Ignore vim swp files
  • Loading branch information
Bob Briski authored and Bob Briski committed Jul 30, 2012
1 parent 0cdcf05 commit d74bf9a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Gemfile.lock
pkg
pkg
*swp
8 changes: 7 additions & 1 deletion lib/batchy/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ def error
return err if err.blank?

backtrace = read_attribute(:backtrace)
err.set_backtrace(backtrace)
if err.respond_to?(:set_backtrace)
err.set_backtrace(backtrace)
else
def err.backtrace
nil
end
end

err
end
Expand Down
2 changes: 1 addition & 1 deletion lib/batchy/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Batchy
VERSION = "0.2.3"
VERSION = "0.2.4"
end
9 changes: 9 additions & 0 deletions spec/batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@
@batch.error.backtrace.should == backtrace
end

it 'should be able to handle a string in the error field' do
@batch.start
@batch.error = "This is an error"
@batch.finish!

@batch.error.should == "This is an error"
@batch.error.backtrace.should be_nil
end

describe 'parents' do
it 'should set its parent' do
child = FactoryGirl.create(:batch)
Expand Down

0 comments on commit d74bf9a

Please sign in to comment.