Error
- group harp_error
- With a few exceptions almost all HARP functions return an integer that indicate whether the function was able to perform its operations successfully. The return value will be 0 on success and -1 otherwise. In case you get a -1 you can look at the global variable harp_errno for a precise error code. Each error code and its meaning is described in this section. You will also be able to retrieve a character string with an error description via the harp_errno_to_string() function. This function will return either the default error message for the error code, or a custom error message. A custom error message will only be returned if the error code you pass to harp_errno_to_string() is equal to the last error that occurred and if this last error was set with a custom error message. The HARP error state can be set with the harp_set_error() function. - Error values - 
HARP_SUCCESS
- Success (no error). 
 - 
HARP_ERROR_OUT_OF_MEMORY
- Out of memory. 
 - 
HARP_ERROR_HDF4
- An error occurred in the HDF4 library. 
 - 
HARP_ERROR_NO_HDF4_SUPPORT
- No HDF4 support built into HARP. 
 - 
HARP_ERROR_HDF5
- An error occurred in the HDF5 library. 
 - 
HARP_ERROR_NO_HDF5_SUPPORT
- No HDF5 support built into HARP. 
 - 
HARP_ERROR_NETCDF
- An error occurred in the netCDF library. 
 - 
HARP_ERROR_CODA
- An error occurred in the CODA library. 
 - 
HARP_ERROR_FILE_NOT_FOUND
- File not found. 
 - 
HARP_ERROR_FILE_OPEN
- Could not open file. 
 - 
HARP_ERROR_FILE_CLOSE
- Could not close file. 
 - 
HARP_ERROR_FILE_READ
- Could not read data from file. 
 - 
HARP_ERROR_FILE_WRITE
- Could not write data to file. 
 - 
HARP_ERROR_INVALID_ARGUMENT
- Invalid argument. 
 - 
HARP_ERROR_INVALID_INDEX
- Invalid index argument. 
 - 
HARP_ERROR_INVALID_NAME
- Invalid name argument. 
 - 
HARP_ERROR_INVALID_FORMAT
- Invalid format in argument. 
 - 
HARP_ERROR_INVALID_DATETIME
- Invalid date/time argument. 
 - 
HARP_ERROR_INVALID_TYPE
- Invalid type. 
 - 
HARP_ERROR_ARRAY_NUM_DIMS_MISMATCH
- Incorrect number of dimensions argument. 
 - 
HARP_ERROR_ARRAY_OUT_OF_BOUNDS
- Array index out of bounds. 
 - 
HARP_ERROR_VARIABLE_NOT_FOUND
- Variable not found. 
 - 
HARP_ERROR_UNIT_CONVERSION
- An error occurred in the unit conversion. 
 - 
HARP_ERROR_OPERATION
- There was an error detected in the product operations. 
 - 
HARP_ERROR_OPERATION_SYNTAX
- There is a syntax error in the string defining the product operations. 
 - 
HARP_ERROR_IMPORT
- An error occurred during product import. 
 - 
HARP_ERROR_EXPORT
- An error occurred during product export. 
 - 
HARP_ERROR_INGESTION
- There was an error in the ingestion of a data product. 
 - 
HARP_ERROR_INGESTION_OPTION_SYNTAX
- There was a syntax error in the ingestion option. 
 - 
HARP_ERROR_INVALID_INGESTION_OPTION
- The ingestion option is not valid for this ingestion. 
 - 
HARP_ERROR_INVALID_INGESTION_OPTION_VALUE
- The ingestion option has value that is not valid for this option. 
 - 
HARP_ERROR_UNSUPPORTED_PRODUCT
- The data product is not supported by the import or ingestion module. 
 - 
HARP_ERROR_NO_DATA
- The operation resulted in an ‘empty’ product. 
 - Functions - 
void harp_add_error_message(const char *message, ...)
- Extend the current error message with additional information. - Parameters:
- message – Error message using printf() format. 
 
 - 
void harp_set_error(int err, const char *message, ...)
- Set the error value and optionally set a custom error message. If message is NULL then the default error message for the error number will be used. - Parameters:
- err – Value of harp_errno. 
- message – Optional error message using printf() format. 
 
 
 - 
const char *harp_errno_to_string(int err)
- Returns a string with the description of the HARP error. If err equals the current HARP error status then this function will return the error message that was last set using harp_set_error(). If the error message argument to harp_set_error() was NULL or if err does not equal the current HARP error status then the default error message for err will be returned. - Parameters:
- err – Value of harp_errno. 
- Returns:
- String with a description of the HARP error. 
 
 - 
int harp_report_warning(const char *message, ...)
- Report a warning message The warning message will be passed on to the current warning handler that was set by harp_set_warning_handler(). If no warning handler was set, then this function will do nothing (and return the value 0). The convention is for warning messages to start with a non-capital letter and not contain end-of-line characters. This is similar to the error messages that can be set with harp_set_error(). Printing of line endings, if these are needed, should be performed by the warning handler. - Parameters:
- message – Warning message using printf() format. 
- Returns:
- Return code from the warning handler. 
 
 - 
int harp_get_warning_handler(int (**print)(const char*, va_list ap))
- Get a reference to the current handler for warning messages If no warning handler was set, the NULL pointer will be returned. - Parameters:
- print – Pointer to the variable in which the reference to the vprintf compatible function will be stored 
- Returns:
- 0, Success.
- -1, Error occurred (check harp_errno).
 
 
 - 
int harp_set_warning_handler(int (*print)(const char*, va_list ap))
- Set handler for warning messages The print function parameter should be a function that resembles vprintf(). The most common case is to provide a function that prints a ‘WARNING’ prefix, prints the message, and adds a newline. For example: The handler function will get called whenever harp_report_warning() is called (several functions inside the HARP library may call harp_report_warning() to report on certain warning conditions). The warning handler can be set before a call to harp_init() is made.- static int print_warning(const char *message, va_list ap) { int result; printf("WARNING: "); result = vprintf(message, ap); printf("\n"); return result; } harp_set_warning_handler(print_warning); - Parameters:
- print – Reference to a vprintf compatible function. 
- Returns:
- 0, Success.
- -1, Error occurred (check harp_errno).
 
 
 - Variables - 
int harp_errno
- Variable that contains the error type. If no error has occurred the variable contains HARP_SUCCESS (0). 
 
- 
HARP_SUCCESS