AerospikeC client manual --- error handling

Source: Internet
Author: User

AerospikeC client manual --- error handling
For error handling, each database operation accepts an as_error object as a parameter. When an error occurs during the operation, the as_error parameter is filled in with the status code and error message. Generally, the as_error parameter is the second parameter for database operations.
As_error provides the following information:
Code-operation status. The type is as_status.
Message-information of the error code. If the operation is completed successfully, this information may be NULL ).
Func-name of the function in which the error occurs. If the capture fails, it may be NULL ).
File-the name of the file where the error occurs. If the capture fails, it may be NULL ).
Line-the row number of the file where the error occurs. If the capture fails, it may be 0.

After the operation is complete, a value of the as_status type is returned, which corresponds to as_error.code. If the operation returns a failure state, it is generally not AEROSPIKE_ OK. The application should check the as_error variable for more information. For more information, see as_status.h.

An as_error variable can be reused for multiple operations. Each operation resets as_error and sets a value when an error occurs.

The following is a simple example of error handling:

If (aerospike_key_put (& as, & err, NULL, & key, & rec )! = AEROSPIKE_ OK) {fprintf (stderr, "err (% d) % s at [% s: % d] \ n", err. code, err. message, err. file, err. line );}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.