The following is the default constructor. This constructor creates an AppError object with an empty message list and does not set any properties.

PUBLIC AppError( )

The following constructor creates an AppError object and assigns the first message on the object with the values from the ErrorMessage and MessageNumber arguments. It also sets the NumMessages property to 1. The error message and message number can be accessed with the GetMessage(1) and GetMessageNum(1) methods.

PUBLIC AppError( INPUT ErrorMessage AS CHARACTER 
                 INPUT MessageNumber AS INTEGER )

The following constructor creates an AppError object with the ReturnValue property set with the value of the ReturnValue parameter. This constructor is used when the AVM implicitly creates an AppError object for a RETURN ERROR ErrorString statement. You can also invoke this constructor directly (not common).

Note: This constructor does not set an error message. If the AddMessage() method is not used to set one, no message is displayed if an object constructed this way is thrown and handled by default error handling.
PUBLIC AppError( INPUT ReturnValue AS CHARACTER )

Below is an example of using an AppError.

  ROUTINE-LEVEL ON ERROR UNDO, THROW.
  DEF VAR ix AS INT.

  RUN proc.  

  CATCH err AS PROGRESS.lang.AppERROR:
    
     MESSAGE "An Error occurred" SKIP
             "returnvalue" err:returnvalue SKIP // This will be empty
             "severity" err:severity SKIP
             VIEW-AS ALERT-BOX.
        
     DO ix = 1 TO err:NUMMESSAGES: // There will be 2            
         MESSAGE err:GetMessage(ix) err:GetMessageNum(ix).
     END.        
  END.

  PROCEDURE proc:
      DEFINE VAR err AS PROGRESS.Lang.Apperror.
    
      err = NEW PROGRESS.Lang.AppError("The car cannot be rented", 1).
      err:addmessage ("No driver's license was provided", 25).
      err:severity = 10.

      /* This is thrown to the caller due to the ROUTINE-LEVEL
         ON ERROR UNDO, THROW directive. */
      UNDO, THROW err.

  END.