Provide error information to the client
- Last Updated: September 14, 2021
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
When an error occurs on the server, you can return useful information to the client using the ERROR-STRING attribute. This attribute can be set at the row level for a system-related or data-related type of error. It can also be set at the temp-table level to provide error summary information for the temp-table.
Provide before-table and after-table row values for the error
The ERROR-STRING attribute is normally set when
an error is encountered during SAVE-ROW-CHANGES. It is
a best practice to provide contextual information about the error from the data in the
corresponding after-table row. Format error information so that the client code can
present the ERROR-STRING directly without modification.
- Before-table has an attribute called the AFTER-ROWID attribute.
- After-table has an attribute called the BEFORE-ROWID attribute.
For example, if an error occurred in SAVE-ROW-CHANGES
for a particular before-table buffer, you can obtain the row values in the
corresponding after-table row by setting the buffer (hBuffer) as
follows:
|
ERROR-STRING after encountering an error during SAVE-ROW-CHANGES. - The
ERRORattribute is set to TRUE by the system if an error occurs. - Using the after-table, find the corresponding record using
the
FIND-BY-ROWID()method and theAFTER-ROWIDfor the before-table record. - Set the
ERROR-STRINGattribute with information about the record in the after-table buffer.
|
Retrieve the ERROR-STRING value in the client
To retrieve ERROR-STRING values in your
client code, you first check if an ERROR was set at the dataset level. If it was
set, iterate through the change dataset’s after-table to find specific errors. For
each error found, you can display and/or process the error messages found in ERROR-STRING. Recall that attributes set in the server
for the before-table and before-table-buffer are automatically set for the
corresponding after-table and after-table buffer.
This code example shows the calling procedure’s code on the client.
|
Next steps
This completes the learning track for datasets. For more detailed information on datasets see the Use ProDataSets guide. For additional developer learning paths see the Developer landing page.