Tip error management in version 7
Error management in version 6
In Sage X3 version 6, the error management was based on the 'GESECRAN' library that was intended for on-the-fly screens displaying errors. The 'GESECRAN' library has been updated to take into account batch and service processes while keeping it organized around the user interface.
Error management in version 7
In Version 7, the code is organized into services.
- Every control is defined as a rule that can be called in service mode.
- Every event returns a status and these statuses are normalized.
- The user interface and the service layer get the return status and manage a collection of warning, information, or error codes with the corresponding messages.
This means that the 'GESECRAN' library should no longer be used and the errors should be managed differently.
The main principles are as follows:
- A collection of error instance is present on every class (this.AERROR).
- The error management is done using three methods:
- "ASETERROR(PROPERTY,MESSAGE,STATUS)" displays an error (the property is given only if the error is attached to a property).
- "ADELETEERROR(PROPERTY" deletes the errors associated with a property (general errors if PROPERTY is empty).
- "AGETMAXERROR(PROPERTY)" gives the maximum error code for the property.
Similarly, there is also a variable called "[L]ASTATUS" that is available on every event. To display errors or warnings, it must be done with one of the following lines:
[L]ASTATUS=Fmet ASETERROR("AMOUNT","the amount has been successfully updated", [V]CST_AINFO)[L]ASTATUS=Fmet ASETERROR("MYPROP","The value of MYPROP is exceeding a usual value", [V]CST_AWARNING)[L]ASTATUS=Fmet ASETERROR("","Global inconsistency for the class xxx", [V]CST_AERROR)[L]ASTATUS=Fmet ASETERROR("","A fatal error occured", [V]CST_AFATAL)
The example given previously is not exactly the code that must be written because text constants must be banned from a script unless no translation is necessary. To learn how to handle the translatable texts, see the Constructing messages for improved localisation document.