- Aug 9, 2022
- 9
- 3
- 1
- Customer Identifier
- E114627
Background
To be able to test the behavior of your application for the correct processing of runtime errors, these errors typically must be provoked programmatically so they are processed by your error handler.Implement erroneous code
In the simplest case it is sufficient to implement code that inevitably leads to a runtime error, for example incrementing an uninitialized variable:
Xbase++:
LOCAL i
i++
Class Exception in xppsys.dll
The xppsys.dll implements the class Exception with which runtime errors for wrong parameter count, wrong parameter type and others can be provoked in Xbase++ program code. This class is implemented in the source file except.prg.The usage is quite simple, it is merely necessary to call the corresponding class method of the Exception class. In the following example, a parameter type error is raised:
Xbase++:
PROCEDURE GetInvoiceItems( cInvoiceId )
IF .NOT. "C" == ValType( cInvoiceId )
Exception():raiseParameterType( cInvoiceId )
ENDIF
...
RETURN
Available errors in xppsys.dll
The following errors are available as of Xbase++ build 2.00.1599. The corresponding general error codes (oError:genCode) from the header file "error.ch" are also shown:
Xbase++:
CLASS Exception
...
EXPORTED:
CLASS METHOD raiseParameterCount() // -> XPP_ERR_ARG_COUNT
CLASS METHOD raiseParameterValue() // -> XPP_ERR_ARG_VALUE
CLASS METHOD raiseParameterType() // -> XPP_ERR_ARG_TYPE
CLASS METHOD raiseObjectState() // -> XPP_ERR_OBJECT_STATE
CLASS METHOD raiseIDSC() // -> XPP_ERR_CORRUPTION
CLASS METHOD raiseOutOfMemory() // -> XPP_ERR_MEMORY_FULL
CLASS METHOD raiseMemberVarAccess() // -> XPP_ERR_MEMBERVAR_ACCESS
CLASS METHOD raiseNotSupported() // -> XPP_ERR_NOT_SUPPORTED
CLASS METHOD raiseSaveNonPersistent() // -> XPP_ERR_SAVE_UNSUPPORTED
CLASS METHOD raiseWrongAppType() // -> XPP_ERR_WRONG_APPTYPE
...
ENDCLASS
Last edited by a moderator: