modify function signatures to allow passing back errors
Fixes https://github.com/libfann/fann/issues/69
This is completely superfluous because the struct fann_train_data can be cast to a fann_error:
/* Struct: struct fann_error
Structure used to store error-related information, both
<struct fann> and <struct fann_train_data> can be casted to this type.
See also:
<fann_set_error_log>, <fann_get_errno>
*/
If you want to get the error do something like this:
struct fann_train_data *data = fann_read_train_from_file(filename);
struct fann_error *err = (struct fann_error *)data;
if(err->errno_f != FANN_E_NO_ERROR) {
// do something
}
Or use one of the many errno functions in fann_error.c .
okay, I now changed the patch to a minimal, non-API-changing modification. It just sets ann->errno_f after failing to load training data. It's not the exact error and there is no error message, but at least we can detect an error now by reading errno_f.
I would suggest to use fann_error and possibly create a new error type for that purpose so it's more consistent and also the message is set.
We should probably review PR #80(?) and get it working, as it supports a new way to handle errors.
Edit: Ignore this comment.
@andersfylling, what do you mean by "new way to handle errors"? I went through the PR you mention and could only find a commit mentioning the "error function", i.e. the function that is minimized during training.
I agree that it would be nice if we could make error handling more consistent and programmatic in FANN, without output to stderr. This PR might be a good first step for it. (I haven't reviewed it though, so I might be wrong.)