# FANN Error Handling

Errors from the fann library are usually reported on stderr. It is however possible to redirect these error messages to a file, or completely ignore them by the fann_set_error_log function.

It is also possible to inspect the last error message by using the fann_get_errno and fann_get_errstr functions.

Summary

FANN Error Handling | Errors from the fann library are usually reported on stderr.
fann_errno_enum | Used to define error events on struct fann and struct fann_train_data.
Error Handling |
fann_set_error_log | Change where errors are logged to.
fann_get_errno | Returns the last error number.
fann_reset_errno | Resets the last error number.
fann_reset_errstr | Resets the last error string.
fann_get_errstr | Returns the last errstr.
fann_print_error | Prints the last error to stderr.

### fann_errno_enum

Used to define error events on struct fann and struct fann_train_data.

#### See also

fann_get_errno, fann_reset_errno, fann_get_errstr

FANN_E_NO_ERROR | No error
FANN_E_CANT_OPEN_CONFIG_R | Unable to open configuration file for reading
FANN_E_CANT_OPEN_CONFIG_W | Unable to open configuration file for writing
FANN_E_WRONG_CONFIG_VERSION | Wrong version of configuration file
FANN_E_CANT_READ_CONFIG | Error reading info from configuration file
FANN_E_CANT_READ_NEURON | Error reading neuron info from configuration file
FANN_E_CANT_READ_CONNECTIONS | Error reading connections from configuration file
FANN_E_WRONG_NUM_CONNECTIONS | Number of connections not equal to the number expected
FANN_E_CANT_OPEN_TD_W | Unable to open train data file for writing
FANN_E_CANT_OPEN_TD_R | Unable to open train data file for reading
FANN_E_CANT_READ_TD | Error reading training data from file
FANN_E_CANT_ALLOCATE_MEM | Unable to allocate memory
FANN_E_CANT_TRAIN_ACTIVATION | Unable to train with the selected activation function
FANN_E_CANT_USE_ACTIVATION | Unable to use the selected activation function
FANN_E_TRAIN_DATA_MISMATCH | Irreconcilable differences between two struct fann_train_data structures
FANN_E_CANT_USE_TRAIN_ALG | Unable to use the selected training algorithm
FANN_E_TRAIN_DATA_SUBSET | Trying to take subset which is not within the training set
FANN_E_INDEX_OUT_OF_BOUND | Index is out of bound
FANN_E_SCALE_NOT_PRESENT | Scaling parameters not present

### Error Handling

### fann_set_error_log

> FANN_EXTERNAL void FANN_API fann_set_error_log( | struct | fann_error | * | errdat,
> |  | FILE | * | log_file | )

Change where errors are logged to. Both struct fann and <struct fann_data> can be casted to struct fann_error, so this function can be used to set either of these.

If log_file is NULL, no errors will be printed.

If errdata is NULL, the default log will be set. The default log is the log used when creating struct fann and <struct fann_data>. This default log will also be the default for all new structs that are created.

The default behavior is to log them to stderr.

#### See also

struct fann_error

This function appears in FANN >= 1.1.0.

### fann_get_errno

> FANN_EXTERNAL enum fann_errno_enum FANN_API fann_get_errno(
> | struct | fann_error | * | errdat
> )

Returns the last error number.

#### See also

fann_errno_enum, fann_reset_errno

This function appears in FANN >= 1.1.0.

### fann_reset_errno

> FANN_EXTERNAL void FANN_API fann_reset_errno( | struct | fann_error | * | errdat | )

Resets the last error number.

This function appears in FANN >= 1.1.0.

### fann_reset_errstr

> FANN_EXTERNAL void FANN_API fann_reset_errstr( | struct | fann_error | * | errdat | )

Resets the last error string.

This function appears in FANN >= 1.1.0.

### fann_get_errstr

> FANN_EXTERNAL char *FANN_API fann_get_errstr( | struct | fann_error | * | errdat | )

Returns the last errstr.

This function calls fann_reset_errno and fann_reset_errstr

This function appears in FANN >= 1.1.0.

### fann_print_error

> FANN_EXTERNAL void FANN_API fann_print_error( | struct | fann_error | * | errdat | )

Prints the last error to stderr.

This function appears in FANN >= 1.1.0.

> struct fann

The fast artificial neural network(fann) structure.

> struct fann_train_data

Structure used to store data, for use with training.

> FANN_EXTERNAL void FANN_API fann_set_error_log( | struct | fann_error | * | errdat,
> |  | FILE | * | log_file | )

Change where errors are logged to.

> FANN_EXTERNAL enum fann_errno_enum FANN_API fann_get_errno(
> | struct | fann_error | * | errdat
> )

Returns the last error number.

> FANN_EXTERNAL void FANN_API fann_reset_errno( | struct | fann_error | * | errdat | )

Resets the last error number.

> FANN_EXTERNAL void FANN_API fann_reset_errstr( | struct | fann_error | * | errdat | )

Resets the last error string.

> FANN_EXTERNAL char *FANN_API fann_get_errstr( | struct | fann_error | * | errdat | )

Returns the last errstr.

> FANN_EXTERNAL void FANN_API fann_print_error( | struct | fann_error | * | errdat | )

Prints the last error to stderr.

> struct fann_error

Structure used to store error-related information, both struct fann and struct fann_train_data can be casted to this type.
Used to define error events on struct fann and struct fann_train_data.
Close