ThrowMessage (pass an error and text to the error handler)


Top  Previous  Next

 

ThrowMessage( error id, text ), VIRTUAL, PROC

ThrowMessage

Passes the specified error and text to the error handler object for processing.

error id

A numeric constant, variable, EQUATE, or expression that indicates the error to process.

text

A string constant, variable, EQUATE, or expression to include in the error message.

The ThrowMessage method passes the specified error, including FILEERROR() and FILEERRORCODE() values, and text to the error handler object for processing, then returns the severity level of the error. See Error Class for more about error ids and severity levels.

Implementation: The Init method receives and sets the error handler. The incorporation of the text into the error message depends on the error handler. See Error Class.

Return Data Type:     BYTE

Example:

GlobalErrors ErrorClass                            !declare GlobalErrors object

Access:Client CLASS(FileManager)                   !derive Access:Client object

ValidateField  PROCEDURE(UNSIGNED Id),BYTE,VIRTUAL !prototype validation

             END

Client  FILE,DRIVER('TOPSPEED'),PRE(CLI),THREAD                

IDKey   KEY(CLI:ID),NOCASE,OPT,PRIMARY

Record   RECORD,PRE()

ID        LONG

Name      STRING(20)

StateCode STRING(2)

        END

       END

CODE

!program code

 

Access:Client.ValidateField FUNCTION(UNSIGNED Id)

CODE

IF ID = 3                   !validate statecode (3rd) field

 IF ~CLI:StateCode          !if no statecode,

                            !pass error & text to error handler

  RETURN Access:Client.ThrowMessage(Msg:RequiredField,'StateCode')

 END

END

RETURN Level:Notify

See Also:     Init