.NET developers can process ABL error objects as .NET exceptions. To enable .NET proxies to throw these exceptions, OpenEdge establishes the following exception class hierarchies:

  • General ABL exceptions — A hierarchy of exception classes that extend the Open4GLException class. Open4GLException, in turn, extends the ProException class.
  • DataSet/DataTable exceptions — A ProDataException class that extends the standard System.Data.DataException class.

For a complete object hierarchy see Exception class hierarchy. To learn more about error handling in ABL code,see Introduction to error and condition handling.

Explore RunTime4GLErrorException class

The Runtime4GLErrorException class hierarchy is shown here.
System.Exception
  Progress.Open4GL.Exceptions
    ProException
      Open4GLException
        Runtime4GLException
           RunTime4GLErrorException
             RunTime4GLAppErrorException
   
The following PUBLIC properties are available for classes that inherit from Runtime4GLErrorException class.
  • CallStack provides details including the file and line number that threw the error.
  • NumMsgs provides the number of error messages.
  • Severity provides ABL developers a way to rank their application error objects according to a severity scheme.
The following PUBLIC methods are available for classes that inherit from Runtime4GLErrorException class.
  • GetMessage (int) retrieves the message.
  • GetMessageNum (int) retrieves the message number for lookup.

Access CallStack information

System administrators must enable the ability to store CallStack information during the testing phase. This allows errors to send the file and line number where errors occurred.
  1. Edit the openedge.properties file.
    1. Locate the AppServer.SessMgr properties.
    2. Add -errorstack to the agentStartupParam property.
      [AppServer.SessMgr]
      ...
      agentStartupParam=-T "${catalina.base}/temp" -errorstack
      ...
  2. Save.
When an error is thrown, the message contains CallStack details.
CallStack() procAppErrorThrow server.p at line 57 (usr1/work/oepas1/openedge/server.r)

Runtime system error condition

In this example, a call made from .NET to the poorly written ABL code raises a runtime system error when the procedure attempts to use the int() function on a character.
// required for errors to get thrown back to the client
ROUTINE-LEVEL ON ERROR UNDO, THROW.
PROCEDURE procInt:
  // this raises a RunTime4GLError
  //  attempts to use INT on a character
  INT (‘a’) .
END.

In the .NET client, the exception provides a return message that identifies the issue. The return message is RunTime4GLErrorException.ERROR condition: Invalid character in numeric input a. (76) (7211). The invalid character in a numeric input a (76) (7211), identifies the problem in the ABL code.

Additionally, .NET developers are thrown a specific exception class RunTime4GLErrorException that can help determine how to process the exception.

Throw an application error

You can explicitly throw an error to .NET. This procedure shows the type of statements needed to throw an error. In the ABL code, you would use an UNDO, THROW appErr statement, where appErr is of type Progress.lang.App that maps to the .NET RunTime4GLAppErrorException exception. In this example, the AppError object is used to store a custom message that provides additional details.
ROUTINE-LEVEL ON ERROR UNDO, THROW.
PROCEDURE procAppErrorThrow:
    DEFINE VARIABLE appErr AS Progress.lang.AppError.
    // Note the second parameter creates an error message
    appErr = NEW progress.lang.AppError("Your custom message here", 1).
    UNDO, THROW appErr.
END. 
.NET developers can determine how to handle the exception in the.NET code with the information provided in the exception's message.

Explore Runtime4GLException class

The Runtime4GLException class hierarchy is shown here.
System.Exception
  Progress.Open4GL.Exceptions
    ProException
      Open4GLException
        Runtime4GLException
          RunTime4GLErrorException
            RunTime4GLAppErrorException
          RunTime4GLQuitException
          RunTime4GLStopException
            RunTime4GLLockConflictException
            RunTime4GLStopAfterException
            Runtime4GLStopErrorException
   
The following PUBLIC properties are available for classes that inherit from Runtime4GLException class.
  • hasProcReturnString flags existence of a return string.
  • ProErrorNum error number
  • ProcReturnString get a custom return string

Return custom ProcReturnString

Prior to the addition of the application error, developers may have used the ProcReturnString to customize an error string. ABL developers can use RETURN ERROR with a custom ProcReturnString to communicate information to .NET developers.
PROCEDURE procAppErrorReturn:
  // this code produces a stop 
  RETURN ERROR "ProcAppErrorReturn: My custom return error string".
END.
The exception that is thrown is Progress.Open4GL.Exceptions.RunTime4GLAppErrorException: Error condition: The Server application has returned an error. (7243) (7211). The .NET developer can access the custom message ProcReturnString.
System.Console.Out.WriteLine("ProcErrorNum: " + e.ProErrorNum);
System.Console.Out.WriteLine("HasProcReturnString: " + e.hasProcReturnString());
System.Console.Out.WriteLine("ProcReturnString: " + e.ProcReturnString);
The .NET developer can determine how to handle the exception on the.NET side based on the custom value returned. The .NET developer can then display or process the custom string.
ProcErrorNum: 7243
HasProcReturnString: true
ProcReturnString: ProcAppErrorReturn: My custom return error string

Stop conditions

In this example, an ABL procedure called non-existent.p is not found in the PROPATH.
PROCEDURE procStop:
  // this code produces a stop 
  RUN non-existent.p.
END.
An attempt by the .NET developer to call non-existent.p raises a STOP condition and returns an exception. The return message is Progress.Open4GL.Exceptions.RunTime4GLStopErrorException: ** “non-existent.p” was not found (293) (7211). The exception indicates that the errors is a RunTime4GLStopErrorException which allows the .NET developer to code for that exception.