Apart from the constructor functions (the functions returning pointers to the types defined above); all the functions return a status code, which is 0 if nothing went wrong, and another value in case of error. The following function allow for error handling from the C side.
chfl_strerror
(int status)Get the error message corresponding to an error code.
status
- The error code
chfl_last_error
(void)Get the last error message.
chfl_clear_errors
(void)Clear the last error message.
Available logging level.
Values:
CHFL_LOG_ERROR
= = 0
- Only log on errors.
CHFL_LOG_WARNING
= = 1
- Log warnings and erors.
CHFL_LOG_INFO
= = 2
- Log infos, warnings and errors.
CHFL_LOG_DEBUG
= = 3
- Log everything.
chfl_loglevel
(chfl_log_level_t * level)Get the current maximal logging level.
level
- The logging level
chfl_set_loglevel
(chfl_log_level_t level)Set the current maximal logging level to level
level
- The new logging level
chfl_logfile
(const char * file)Redirect the logs to file
, overwriting the file if it exists.
file
- The filename for the new log file.
chfl_log_stderr
(void)Redirect the logs to the standard error output. This is enabled by default.
The return values for this status code correspond to the following macros:
Status code for success.
Memory error: out of memory, wrong size for arrays parameters, ...
File error: file do not exist, you do not have rights to open it, ...
Error in file formating.
Any other error from Chemfiles.
Error in the C++ standard library.