Skip to content

Commit

Permalink
on error callback
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Oct 24, 2008
1 parent 9729436 commit d50e66b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/em/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def notify_readable
if DisconnectErrors.include? e.message
@pending << [response, sql, blk]
return close
elsif cb = @opts[:on_error]
cb.call(e)
else
raise e
end
Expand Down Expand Up @@ -388,6 +390,14 @@ def SQL(query, &blk) SQL.select(query, &blk) end
}
end

should 'fire error callback with exceptions' do
SQL.settings.update :on_error => proc{ |e|
e.class.should == Mysql::Error
done
}
SQL.select('select 1+ from table'){}
end

end

end

0 comments on commit d50e66b

Please sign in to comment.