|
In the following example, API
make_parallelepiped is called to create a cuboid, and the result of the API is determined (using a conditional statement):
|
|
|
body = make_parallelepiped(width, depth, height);
|
|
result = outcome(body == NULL ? API_FAILED : 0);
|
|
|
If the operation was successful, the result is set to 0; otherwise, the result is set to a generic API failed condition. If some other internal error occurred, the result is set by the error handling code in the
API_BEGIN macro.
API_END closes the roll back and error handling that
API_BEGIN established.
|
|
|
Refer to Chapter 6,
Error Handling and Messaging, for more information about error handling.
|