Index: src/org/jruby/evaluator/EvaluateVisitor.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/evaluator/EvaluateVisitor.java,v
retrieving revision 1.71.2.9
diff -u -r1.71.2.9 EvaluateVisitor.java
--- src/org/jruby/evaluator/EvaluateVisitor.java	3 Mar 2006 18:09:40 -0000	1.71.2.9
+++ src/org/jruby/evaluator/EvaluateVisitor.java	3 Mar 2006 18:17:04 -0000
@@ -1476,7 +1476,7 @@
             je.setSecondaryData(ctx);
 
             state.setCurrentException(je);
-            throw je;
+            //throw je;
         }
     }
     private static final NextThrower nextThrower = new NextThrower();
@@ -1644,7 +1644,8 @@
             
             je.setSecondaryData(ctx);
             
-            throw je;
+            //throw je;
+            state.setCurrentException(je);
     	}
     }
     private static final RedoNodeVisitor redoNodeVisitor = new RedoNodeVisitor();
Index: src/org/jruby/evaluator/EvaluationState.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/evaluator/EvaluationState.java,v
retrieving revision 1.6.2.6
diff -u -r1.6.2.6 EvaluationState.java
--- src/org/jruby/evaluator/EvaluationState.java	3 Mar 2006 18:09:39 -0000	1.6.2.6
+++ src/org/jruby/evaluator/EvaluationState.java	3 Mar 2006 18:17:04 -0000
@@ -39,6 +39,7 @@
 	public final EvaluateVisitor evaluator;
     private UnsynchronizedStack instructionBundleStacks = new UnsynchronizedStack();
     private JumpException currentException;
+    private boolean handlingException;
     
     private class InstructionBundle {
         Instruction instruction;
@@ -251,41 +252,12 @@
     }
     private static final ExceptionRethrower exceptionRethrower = new ExceptionRethrower();
     
-    private static class NextRethrower implements Instruction {
+    private static class ExceptionContinuer implements Instruction {
         public void execute(EvaluationState state, InstructionContext ctx) {
-            JumpException je = new JumpException(JumpException.JumpType.NextJump);
-            
-            je.setPrimaryData(state.getResult());
-            je.setSecondaryData(ctx);
-            
-            throw je;
-        }
-    }
-    private static final NextRethrower nextRethrower = new NextRethrower();
-    
-    private static class RedoRethrower implements Instruction {
-        public void execute(EvaluationState state, InstructionContext ctx) {
-            JumpException je = new JumpException(JumpException.JumpType.RedoJump);
-            
-            je.setPrimaryData(state.getResult());
-            je.setSecondaryData(ctx);
-            
-            throw je;
+            state.handlingException = false;
         }
     }
-    private static final RedoRethrower redoRethrower = new RedoRethrower();
-    
-    private static class BreakRethrower implements Instruction {
-        public void execute(EvaluationState state, InstructionContext ctx) {
-            JumpException je = new JumpException(JumpException.JumpType.BreakJump);
-            
-            je.setPrimaryData(state.getResult());
-            je.setSecondaryData(ctx);
-            
-            throw je;
-        }
-    }
-    private static final BreakRethrower breakRethrower = new BreakRethrower();
+    private static final ExceptionContinuer exceptionContinuer = new ExceptionContinuer();
     
     private static class RaiseRethrower implements Instruction {
         public void execute(EvaluationState state, InstructionContext ctx) {
@@ -296,19 +268,6 @@
     }
     private static final RaiseRethrower raiseRethrower = new RaiseRethrower();
     
-    private static class ReturnRethrower implements Instruction {
-        public void execute(EvaluationState state, InstructionContext ctx) {
-            ReturnNode iVisited = (ReturnNode)ctx;
-            JumpException je = new JumpException(JumpException.JumpType.ReturnJump);
-            
-            je.setPrimaryData(iVisited.getTarget());
-            je.setSecondaryData(state.getResult());
-            
-            throw je;
-        }
-    }
-    private static final ReturnRethrower returnRethrower = new ReturnRethrower();
-    
     private static class Retrier implements Instruction {
         public void execute(EvaluationState state, InstructionContext ctx) {
             // dummy, only used to store the current "retriable" node and clear exceptions after a rescue block
@@ -334,11 +293,7 @@
                     try {
                         executeNext();
                     } catch (JumpException je) {
-                        if (je.getJumpType() == JumpException.JumpType.NextJump) {
-                            handleNext(je);
-                        } else if (je.getJumpType() == JumpException.JumpType.RedoJump) {
-                            handleRedo(je);
-                        } else if (je.getJumpType() == JumpException.JumpType.BreakJump) {
+                        if (je.getJumpType() == JumpException.JumpType.BreakJump) {
                             handleBreak(je);
                         } else if (je.getJumpType() == JumpException.JumpType.RaiseJump) {
                             handleRaise(je);
@@ -350,6 +305,14 @@
                             handleThrow(je);
                         }
                     }
+                    
+                    if (currentException != null && !handlingException) {
+                        if (currentException.getJumpType() == JumpException.JumpType.RedoJump) {
+                            handleRedo(currentException);
+                        } else if (currentException.getJumpType() == JumpException.JumpType.NextJump) {
+                            handleNext(currentException);
+                        }
+                    }
                 }
             } catch (StackOverflowError soe) {
                 // TODO: perhaps a better place to catch this (although it will go away)
@@ -370,7 +333,8 @@
             if (ib.ensured) {
                 // exec ensured node, return to "nexting" afterwards
                 popCurrentInstruction();
-                addInstruction(iVisited, exceptionRethrower);
+                handlingException = true;
+                addInstruction(iVisited, exceptionContinuer);
                 addInstructionBundle(ib);
                 return;
             }
@@ -384,6 +348,7 @@
             // pop the redoable and continue
             popCurrentInstruction();
             setCurrentException(null);
+            handlingException = false;
         }
     }
     
@@ -395,6 +360,7 @@
             if (ib.ensured) {
                 // exec ensured node, return to "redoing" afterwards
                 popCurrentInstruction();
+                handlingException = true;
                 addInstruction(iVisited, exceptionRethrower);
                 addInstructionBundle(ib);
                 return;
@@ -412,6 +378,7 @@
             addRedoMarker(nodeToRedo);
             addNodeInstruction(nodeToRedo);
             setCurrentException(null);
+            handlingException = false;
         }
     }
     

