Project

General

Profile

sys-error.patch

eclipse patch for changes on sys error handling - Marian Edu, 03/28/2020 12:16 PM

Download (7.91 KB)

View differences:

src/com/goldencode/p2j/oo/lang/AppError.java
72 72
import static com.goldencode.p2j.util.BlockManager.*;
73 73
import static com.goldencode.p2j.report.ReportConstants.*;
74 74

  
75
import com.goldencode.p2j.NumberedException;
76 75
import com.goldencode.p2j.util.*;
77 76
import com.goldencode.p2j.util.InternalEntry.Type;
78 77

  
......
146 145
      integer num = TypeFactory.initInput(_num);
147 146
      internalProcedure(this, "__lang_AppError_constructor__", new Block((Body) () -> 
148 147
      {
149
         __lang_ProError_constructor__();
150
         
151
         addMessage(msg, num);
148
         __lang_ProError_constructor__(msg, num);
152 149
      }));
153 150
   }
154 151

  
......
262 259
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_PARTIAL)
263 260
   public void addMessage(character msg, integer num)
264 261
   {
265
      // TODO: validate the index or message?
266

  
267
      int inum = num.isUnknown() ? 0 : num.intValue();
268
      errors.add(new NumberedException(msg.toStringMessage(), inum));
262
      super.addMessage(msg, num);
269 263
   }
270 264
}
src/com/goldencode/p2j/oo/lang/ProError.java
145 145
         __lang_BaseObject_constructor__();
146 146
      }));
147 147
   }
148
   
149
   /**
150
    * Explicit method associated with a legacy constructor for the
151
    * <code>Progress.Lang.ProError</code> class.
152
    * 
153
    * @param    _msg
154
    *           The message.
155
    * @param    _num
156
    *           The message number.
157
    */
158
   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
159
   {
160
      @LegacyParameter(name = "msg",  type = "CHARACTER", mode = "INPUT"),
161
      @LegacyParameter(name = "num",  type = "INTEGER", mode = "INPUT"),
162
   })
163
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
164
   protected void __lang_ProError_constructor__(character _msg, integer _num)
165
   {
166
      character msg = TypeFactory.initInput(_msg);
167
      integer num = TypeFactory.initInput(_num);
168
      internalProcedure(this, "__lang_ProError_constructor__", new Block((Body) () -> 
169
      {
170
         __lang_ProError_constructor__();
171
         
172
         addMessage(msg, num);
173
      }));
174
   }
148 175

  
149 176
   /**
150 177
    * Get the number of messages.
......
272 299
      
273 300
      return true;
274 301
   }
302
   
303
   protected void addMessage(character msg, integer num)
304
   {
305
      // TODO: validate the index or message?
306

  
307
      int inum = num.isUnknown() ? 0 : num.intValue();
308
      errors.add(new NumberedException(msg.toStringMessage(), inum));
309
   }
275 310
}
src/com/goldencode/p2j/oo/lang/SysError.java
68 68
import static com.goldencode.p2j.util.BlockManager.externalProcedure;
69 69
import static com.goldencode.p2j.report.ReportConstants.*;
70 70
import static com.goldencode.p2j.util.BlockManager.internalProcedure;
71
import static com.goldencode.p2j.report.ReportConstants.*;
72 71

  
73 72
import com.goldencode.p2j.util.*;
74 73
import com.goldencode.p2j.util.InternalEntry.Type;
......
77 76
 * Implementation of the Progress.Lang.SysError builtin class.
78 77
 */
79 78
@LegacyResource(resource = "Progress.Lang.SysError")
80
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_BASIC)
79
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
81 80
public class SysError
82 81
extends ProError
83 82
{
......
96 95
    * <code>Progress.Lang.SysError</code> class.
97 96
    */
98 97
   @LegacySignature(type = Type.CONSTRUCTOR)
99
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_BASIC)
98
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
100 99
   public void __lang_SysError_constructor__()
101 100
   {
102 101
      internalProcedure(this, "__lang_SysError_constructor__", new Block((Body) () -> 
......
104 103
         __lang_ProError_constructor__();
105 104
      }));
106 105
   }
106
   
107
   /**
108
    * Explicit method associated with a legacy constructor for the
109
    * <code>Progress.Lang.SysError</code> class.
110
    * 
111
    * @param    _msg
112
    *           The message.
113
    * @param    _num
114
    *           The message number.
115
    */
116
   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
117
   {
118
      @LegacyParameter(name = "msg",  type = "CHARACTER", mode = "INPUT"),
119
      @LegacyParameter(name = "num",  type = "INTEGER", mode = "INPUT"),
120
   })
121
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
122
   public void __lang_SysError_constructor__(character _msg, integer _num)
123
   {
124
      character msg = TypeFactory.initInput(_msg);
125
      integer num = TypeFactory.initInput(_num);
126
      internalProcedure(this, "__lang_SysError_constructor__", new Block((Body) () -> 
127
      {
128
         __lang_ProError_constructor__(msg, num);
129
      }));
130
   }
131
   
132
   /**
133
    * Create a new SysError instance and return it as a legacy object. 
134
    * 
135
    * @param    retVal
136
    *           The return value.
137
    */
138
   public static object<SysError> newInstance(character msg, integer num)
139
   {
140
      return ObjectOps.newInstance(SysError.class, "II", msg, num);
141
   }
142
   
143
   /**
144
    * Create a new SysError instance and return it as a legacy object. 
145
    * 
146
    * @param    retVal
147
    *           The return value.
148
    */
149
   public static object<SysError> newInstance(String msg, int num)
150
   {
151
      return ObjectOps.newInstance(SysError.class, "II", msg, num);
152
   }
107 153
}
src/com/goldencode/p2j/util/BlockManager.java
6759 6759
      
6760 6760
      WorkArea wa = work.get();
6761 6761
      
6762
      character retVal = ((AppError) error.ref()).getReturnValue();
6763
      if (!retVal.isUnknown() && !retVal.toStringMessage().isEmpty())
6764
      {
6765
         wa.cfops.setReturnValue(retVal);
6762
      if (error.ref() instanceof AppError) {
6763
         character retVal = ((AppError) error.ref()).getReturnValue();
6764
         if (!retVal.isUnknown() && !retVal.toStringMessage().isEmpty())
6765
         {
6766
            wa.cfops.setReturnValue(retVal);
6767
         }
6766 6768
      }
6767 6769

  
6768 6770
      LegacyErrorException lex = new LegacyErrorException(error, true);
src/com/goldencode/p2j/util/ErrorManager.java
619 619
         srv.setPending(true);
620 620
         
621 621
         LegacyError err = lex.getErrorRef();
622
         if (!(err instanceof AppError && ((AppError) err).isFromReturn()))
622
         if (!(err instanceof AppError) || !((AppError) err).isFromReturn())
623 623
         {
624
            AppError appErr = (AppError) err;
625
            int errnum = appErr.getMessageNum(new integer(1)).intValue();
626
            String errmsg = appErr.getMessage(new integer(1)).toStringMessage();
624
            ProError proErr = (ProError) err;
625
            int errnum = proErr.getMessageNum(new integer(1)).intValue();
626
            String errmsg = proErr.getMessage(new integer(1)).toStringMessage();
627 627
            wa.pendingErrorStatus.errorList.add(new ErrorEntry(errnum, errmsg));
628 628
            addRaisedCondition(new int[] { errnum });
629 629
         }
......
1447 1447
            {
1448 1448
               // display the error message (because of pause processing, an
1449 1449
               // endkey, error... even stop condition can be generated here)
1450
               displayError(errmsg);
1450
               // displayError(errmsg);
1451
               BlockManager.returnError(SysError.newInstance(text, num));
1451 1452
            }
1452 1453
            
1453 1454
            catch (ConditionException err)