=== modified file 'src/com/goldencode/p2j/util/BlockManager.java'
--- old/src/com/goldencode/p2j/util/BlockManager.java	2024-06-11 20:58:41 +0000
+++ new/src/com/goldencode/p2j/util/BlockManager.java	2024-06-26 07:22:23 +0000
@@ -2,7 +2,7 @@
 ** Module   : BlockManager.java
 ** Abstract : common "scaffolding" for executing Progress-compatible code blocks
 **
-** Copyright (c) 2008-2023, Golden Code Development Corporation.
+** Copyright (c) 2008-2024, Golden Code Development Corporation.
 **
 ** -#- -I- --Date-- --JPRM-- ----------------------------------Description-----------------------------------
 ** 001 GES 20080509   @38517 Created initial version. Implements the core
@@ -283,6 +283,9 @@
 **     DDF 20240524          Revert re-throw change and avoid NPE when matching condition is null.
 ** 083 CA  20240609          Once a structured exception is re-thrown, mark it as explicit, so it can be 
 **                           re-thrown via top-level blocks.
+** 084 CA  20240625          Certain database-level ERROR conditions (like 132/buffer already exists with) 
+**                           must be processed as if BLOCK-LEVEL ON ERROR UNDO, THROW is set (in other words,
+**                           it can get morphed into a strcutured exceptions). 
 */
 
 /*
@@ -8579,6 +8582,39 @@
     *
     * @param   wa
     *          The {@link WorkArea} instance.
+    * @param   forceBlockLevelUndoThrow
+    *          Flag indicating that, when nothing else matches, a BLOCK-LEVEL UNDO, THROW exists by default.
+    *          
+    * @return  see above.
+    */
+   static boolean mustManageLegacyError(WorkArea wa, boolean forceBlockLevelUndoThrow)
+   {
+      return wa.pm._thisProcedure() != null && 
+            (forceBlockLevelUndoThrow ||
+             (wa.tm.isRootNestingLevel() && AppServerManager.isRemote() && wa.pm.isRoutineLevelUndoThrow()) || 
+             (wa.tm.isTopLevelBlock() && wa.pm.isRoutineLevelUndoThrow())                                   || 
+             wa.pm.isBlockLevelUndoThrow());
+   }   
+   /**
+    * Check if the top-level block is ROUTINE-LEVEL UNDO, THROW or the current program is 
+    * BLOCK-LEVEL UNDO, THROW.
+    * 
+    * @param   forceBlockLevelUndoThrow
+    *          Flag indicating that, when nothing else matches, a BLOCK-LEVEL UNDO, THROW exists by default.
+    * 
+    * @return  see above.
+    */
+   static boolean mustManageLegacyError(boolean forceBlockLevelUndoThrow)
+   {
+      return mustManageLegacyError(work.obtain(), forceBlockLevelUndoThrow);
+   }
+   
+   /**
+    * Check if the top-level block is ROUTINE-LEVEL UNDO, THROW or the current program is 
+    * BLOCK-LEVEL UNDO, THROW.
+    *
+    * @param   wa
+    *          The {@link WorkArea} instance.
     *          
     * @return  see above.
     */
@@ -11580,7 +11616,7 @@
          if (imple != null)
          {
             canThrow = canThrow || (imple.action == Action.THROW);
-            noThrowOnError = (imple.action != Action.THROW);
+            noThrowOnError = !lex.isExplicit() && (imple.action != Action.THROW);
          }
       }
       

=== modified file 'src/com/goldencode/p2j/util/ErrorManager.java'
--- old/src/com/goldencode/p2j/util/ErrorManager.java	2024-06-11 20:58:41 +0000
+++ new/src/com/goldencode/p2j/util/ErrorManager.java	2024-06-26 07:48:50 +0000
@@ -277,6 +277,9 @@
 ** 092 CA  20240609          An ERROR condition must be triggered in the caller (outside of the top-level 
 **                           block) is current file has ROUTINE-/BLOCK-LEVEL statetements and this condition
 **                           can't be morphed in a structured exception in the current stacktrace.
+** 095 CA  20240625          Certain database-level ERROR conditions (like 132/buffer already exists with) 
+**                           must be processed as if BLOCK-LEVEL ON ERROR UNDO, THROW is set (in other words,
+**                           it can get morphed into a strcutured exceptions). 
 */
 
 /*
@@ -1930,6 +1933,14 @@
       boolean silent = isSilentError();
       boolean manageLegacyError = da.mustThrowLegacyError();
       boolean mustManageError = !manageLegacyError && da.mustManageLegacyError();
+      boolean forceExplicitException = false;
+      
+      if (!manageLegacyError && nums[0] == 132 && !ProcedureManager.getProcedureHelper().isBlockLevelUndoThrow())
+      {
+         forceExplicitException = true;
+         manageLegacyError = da.mustThrowLegacyError(true);
+         mustManageError = !manageLegacyError && da.mustManageLegacyError(true);
+      }
       
       boolean throwError = false;
       
@@ -2010,6 +2021,7 @@
             
             if (last && throwError)
             {
+               work.get().forceExplicit = forceExplicitException;
                throw new DeferredLegacyErrorException();
             }
 
@@ -2919,6 +2931,18 @@
    {
       return BlockManager.mustManageLegacyError();
    }
+   /**
+    * Check if the current ERROR condition must be raised as a legacy {@link SysError}.
+    * 
+    * @param   forceBlockLevelUndoThrow
+    *          Flag indicating that, when nothing else matches, a BLOCK-LEVEL UNDO, THROW exists by default.
+    *          
+    * @return  see above.
+    */
+   public static boolean mustManageLegacyError(boolean forceBlockLevelUndoThrow)
+   {
+      return BlockManager.mustManageLegacyError(forceBlockLevelUndoThrow);
+   }
    
    /**
     * Check if the current ERROR condition must be raised as a legacy {@link SysError}.
@@ -2927,8 +2951,21 @@
     */
    public static boolean mustThrowLegacyError()
    {
+      return mustThrowLegacyError(false);
+   }
+   
+   /**
+    * Check if the current ERROR condition must be raised as a legacy {@link SysError}.
+    *
+    * @param   forceBlockLevelUndoThrow
+    *          Flag indicating that, when nothing else matches, a BLOCK-LEVEL UNDO, THROW exists by default.
+    * 
+    * @return  see above.
+    */
+   public static boolean mustThrowLegacyError(boolean forceBlockLevelUndoThrow)
+   {
       return BlockManager.hasLegacyError(SysError.class, 0) ||
-             (BlockManager.mustManageLegacyError() && 
+             (BlockManager.mustManageLegacyError(forceBlockLevelUndoThrow) && 
               (BlockManager.hasLegacyError(SysError.class, -1) || 
                (TransactionManager.isRootNestingLevel() && AppServerManager.isRemote())));
    }
@@ -2982,7 +3019,10 @@
       object<? extends SysError> legacyError = wa.legacyError;
       wa.legacyError = null;
       
-      return new LegacyErrorException(legacyError);
+      LegacyErrorException lex = new LegacyErrorException(legacyError);
+      lex.setExplicit(wa.forceExplicit);
+      wa.forceExplicit = false;
+      return lex;
    }
 
    /**
@@ -4722,6 +4762,12 @@
          return false;
       }
       
+      @Override
+      public boolean mustManageLegacyError(boolean forceBlockLevelUndoThrow)
+      {
+         return false;
+      }
+      
       /**
        * Check if the current ERROR condition must be raised as a legacy {@link SysError}.
        * 
@@ -4732,6 +4778,10 @@
          return false;
       }
       
+      public boolean mustThrowLegacyError(boolean forceBlockLevelUndoThrow)
+      {
+         return false;
+      }
       
       /**
        * Record the specified error message and number, to be later thrown as a 
@@ -4830,6 +4880,20 @@
       /**
        * Check if the current ERROR condition must be raised as a legacy {@link SysError}.
        * 
+       * @param   forceBlockLevelUndoThrow
+       *          Flag indicating that, when nothing else matches, a BLOCK-LEVEL UNDO, THROW exists by default.
+       *          
+       * @return  see above.
+       */
+      @Override
+      public boolean mustManageLegacyError(boolean forceBlockLevelUndoThrow)
+      {
+         return ErrorManager.mustManageLegacyError(forceBlockLevelUndoThrow);
+      }
+      
+      /**
+       * Check if the current ERROR condition must be raised as a legacy {@link SysError}.
+       * 
        * @return  see above.
        */
       @Override
@@ -4839,6 +4903,20 @@
       }
       
       /**
+       * Check if the current ERROR condition must be raised as a legacy {@link SysError}.
+       *
+       * @param   forceBlockLevelUndoThrow
+       *          Flag indicating that, when nothing else matches, a BLOCK-LEVEL UNDO, THROW exists by default.
+       * 
+       * @return  see above.
+       */
+      @Override
+      public boolean mustThrowLegacyError(boolean forceBlockLevelUndoThrow)
+      {
+         return ErrorManager.mustThrowLegacyError(forceBlockLevelUndoThrow);
+      }
+      
+      /**
        * Record the specified error message and number, to be later thrown as a 
        * {@link LegacyErrorException}.
        * 
@@ -5020,6 +5098,57 @@
       {
          wa.silent = value;
       }
+      
+      /**
+       * Check if the top-level block is ROUTINE-LEVEL UNDO, THROW or the current program is 
+       * BLOCK-LEVEL UNDO, THROW.
+       *
+       * @return  see above.
+       */
+      @Override
+      public boolean mustManageLegacyError()
+      {
+         return ErrorManager.mustManageLegacyError();
+      }
+
+      /**
+       * Check if the current ERROR condition must be raised as a legacy {@link SysError}.
+       * 
+       * @param   forceBlockLevelUndoThrow
+       *          Flag indicating that, when nothing else matches, a BLOCK-LEVEL UNDO, THROW exists by default.
+       *          
+       * @return  see above.
+       */
+      @Override
+      public boolean mustManageLegacyError(boolean forceBlockLevelUndoThrow)
+      {
+         return ErrorManager.mustManageLegacyError(forceBlockLevelUndoThrow);
+      }
+      
+      /**
+       * Check if the current ERROR condition must be raised as a legacy {@link SysError}.
+       *
+       * @return  see above.
+       */
+      @Override
+      public boolean mustThrowLegacyError()
+      {
+         return ErrorManager.mustThrowLegacyError();
+      }
+      
+      /**
+       * Check if the current ERROR condition must be raised as a legacy {@link SysError}.
+       *
+       * @param   forceBlockLevelUndoThrow
+       *          Flag indicating that, when nothing else matches, a BLOCK-LEVEL UNDO, THROW exists by default.
+       * 
+       * @return  see above.
+       */
+      @Override
+      public boolean mustThrowLegacyError(boolean forceBlockLevelUndoThrow)
+      {
+         return ErrorManager.mustThrowLegacyError(forceBlockLevelUndoThrow);
+      }
    }
    
    /**

=== modified file 'src/com/goldencode/p2j/util/RemoteErrorData.java'
--- old/src/com/goldencode/p2j/util/RemoteErrorData.java	2023-08-02 17:45:41 +0000
+++ new/src/com/goldencode/p2j/util/RemoteErrorData.java	2024-06-26 07:32:59 +0000
@@ -2,7 +2,7 @@
 ** Module : RemoteErrorData.java
 ** Public : provides remote access to ErrorManager data
 **
-** Copyright (c) 2005-2023, Golden Code Development Corporation.
+** Copyright (c) 2005-2024, Golden Code Development Corporation.
 **
 ** -#- -I- --Date-- --JPRM-- ----------------------------------Description----------------------------------
 ** 001 NVS 20060303   @24884 Created initial version.
@@ -29,6 +29,9 @@
 **                           be morphed into a legacy SysError exception, and not raise an ERROR condition.
 ** 013 GBB 20230313          New method writeLog added.
 ** 014 TT  20230614          Added the functionality for session:suppress-warnings-list.
+** 016 CA  20240625          Certain database-level ERROR conditions (like 132/buffer already exists with) 
+**                           must be processed as if BLOCK-LEVEL ON ERROR UNDO, THROW is set (in other words,
+**                           it can get morphed into a strcutured exceptions). 
 */
 
 /*
@@ -189,6 +192,16 @@
     * @return  see above.
     */
    public boolean mustManageLegacyError();
+   /**
+    * Check if the top-level block is ROUTINE-LEVEL UNDO, THROW or the current program is 
+    * BLOCK-LEVEL UNDO, THROW.
+    * 
+    * @param   forceBlockLevelUndoThrow
+    *          Flag indicating that, when nothing else matches, a BLOCK-LEVEL UNDO, THROW exists by default.
+    * 
+    * @return  see above.
+    */
+   public boolean mustManageLegacyError(boolean forceBlockLevelUndoThrow);
    
    /**
     * Check if the current ERROR condition must be raised as a legacy {@link SysError}.
@@ -196,6 +209,15 @@
     * @return  see above.
     */
    public boolean mustThrowLegacyError();
+   /**
+    * Check if the current ERROR condition must be raised as a legacy {@link SysError}.
+    * 
+    * @param   forceBlockLevelUndoThrow
+    *          Flag indicating that, when nothing else matches, a BLOCK-LEVEL UNDO, THROW exists by default.
+    *          
+    * @return  see above.
+    */
+   public boolean mustThrowLegacyError(boolean forceBlockLevelUndoThrow);
 
    /**
     * Record the specified error message and number, to be later thrown as a 

