Permalink
Browse files

fix raising error if the code is executed in a rescue block

  • Loading branch information...
1 parent 5a2094f commit 8675678b6e9663f9e22c11551657041b7ff42770 @copiousfreetime committed Nov 17, 2008
Showing with 6 additions and 18 deletions.
  1. +1 −3 lib/amalgalite/core_ext/kernel/require.rb
  2. +1 −14 lib/amalgalite/requires.rb
  3. +4 −1 lib/amalgalite/statement.rb
@@ -7,9 +7,7 @@ module Kernel
# amalgalite database.
#
def require( filename )
- if Amalgalite::Requires.use_original_require? then
- loaded = amalgalite_original_require( filename )
- end
+ loaded = amalgalite_original_require( filename )
rescue LoadError => load_error
if load_error.message =~ /#{Regexp.escape filename}\z/ then
loaded = Amalgalite::Requires.require( filename )
View
@@ -18,20 +18,6 @@ def load_path
end
#
- # Global option to say whether to use the global ruby requires or not
- #
- def use_original_require
- @use_original_require ||= true
- end
-
- #
- # Set whether or not to fallback to the original ruby requires or not.
- #
- def use_original_require=( use_it )
- @use_original_require ||= use_it
- end
-
- #
# Allocate a database connection to the given filename
#
def db_connection_to( dbfile_name )
@@ -109,6 +95,7 @@ def require( filename )
return false
else
begin
+ filename = filename.gsub(/\.rb\Z/,'')
rows = db_connection.execute(sql, filename)
if rows.size > 0 then
row = rows.first
@@ -83,6 +83,9 @@ def reset_for_next_execute!
def execute( *params )
bind( *params )
begin
+ # save the error state at the beginning of the execution. We only want to
+ # reraise the error if it was raised during this execution.
+ s_before = $!
if block_given? then
while row = next_row
yield row
@@ -96,7 +99,7 @@ def execute( *params )
reset_for_next_execute!
rescue => e
end
- raise s if s
+ raise s if s != s_before
end
end

0 comments on commit 8675678

Please sign in to comment.