Title: [780] trunk/activerecord-jdbc/src/java/JdbcAdapterInternalService.java: Wrap exceptions so they're seen by regular Ruby
Revision
780
Author
olabini
Date
2007-10-29 17:25:33 -0400 (Mon, 29 Oct 2007)

Log Message

Wrap exceptions so they're seen by regular Ruby

Modified Paths


Diff

Modified: trunk/activerecord-jdbc/src/java/JdbcAdapterInternalService.java (779 => 780)


--- trunk/activerecord-jdbc/src/java/JdbcAdapterInternalService.java	2007-10-26 18:13:27 UTC (rev 779)
+++ trunk/activerecord-jdbc/src/java/JdbcAdapterInternalService.java	2007-10-29 21:25:33 UTC (rev 780)
@@ -299,7 +299,7 @@
                         continue;
                     }
                 }
-                throw e;
+                throw wrap(recv, e);
             } finally {
                 try {
                     rs.close();
@@ -398,7 +398,7 @@
                         continue;
                     }
                 }
-                throw e;
+                throw wrap(recv, e);
             }
         }    
     }
@@ -515,6 +515,10 @@
         return id;
     }
 
+    private static RuntimeException wrap(IRubyObject recv, Throwable exception) {
+        return recv.getRuntime().newArgumentError(exception.getMessage());
+    }
+
     public static IRubyObject execute_update(IRubyObject recv, IRubyObject sql) throws SQLException {
         int tries = 10;
         while(true) {
@@ -530,7 +534,8 @@
                         continue;
                     }
                 }
-                throw e;
+
+                throw wrap(recv, e);
             } finally {
                 if(null != stmt) {
                     try {
@@ -562,7 +567,7 @@
                         continue;
                     }
                 }
-                throw e;
+                throw wrap(recv, e);
             } finally {
                 if(null != stmt) {
                     try {
@@ -589,7 +594,7 @@
                         continue;
                     }
                 }
-                throw e;
+                throw wrap(recv, e);
             } finally {
                 if(null != stmt) {
                     try {
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to