ferror 1.4.1
FERROR is a library to assist with error handling in Fortran projects.
All Classes Namespaces Files Functions Variables Typedefs Pages
ferror.h File Reference
#include <stdbool.h>
Include dependency graph for ferror.h:

Go to the source code of this file.

Classes

struct  error_handler
 A C compatible type encapsulating an errors object. More...
 

Typedefs

typedef void(* error_callback) (void *args)
 Describes a function to call when an error is encountered. More...
 

Functions

void alloc_error_handler (error_handler *obj)
 Initializes a new error handler object. More...
 
void free_error_handler (error_handler *obj)
 Frees resources held by the error_handler object. More...
 
void get_log_filename (const error_handler *err, char *fname, int *nfname)
 Gets the name of the error log file. More...
 
void set_log_filename (error_handler *err, const char *fname)
 Sets the error log filename. More...
 
void report_error (error_handler *err, const char *fcn, const char *msg, int flag)
 Reports an error condition to the user. More...
 
void report_warning (error_handler *err, const char *fcn, const char *msg, int flag)
 Reports a warning condition to the user. More...
 
void log_error (const error_handler *err, const char *fcn, const char *msg, int flag)
 Writes an error log file. More...
 
bool has_error_occurred (const error_handler *err)
 Tests to see if an error has been encountered. More...
 
void reset_error_status (error_handler *err)
 Resets the error status flag to false, and the current error flag to zero. More...
 
bool has_warning_occurred (const error_handler *err)
 Tests to see if a warning has been encountered. More...
 
void reset_warning_status (error_handler *err)
 Resets the warning status flag to false, and the current warning flag to zero. More...
 
int get_error_flag (const error_handler *err)
 Gets the current error flag. More...
 
int get_warning_flag (const error_handler *err)
 Gets the current warning flag. More...
 
bool get_exit_on_error (const error_handler *err)
 Gets a logical value determining if the application should be terminated when an error is encountered. More...
 
void set_exit_on_error (error_handler *err, bool x)
 Sets a logical value determining if the application should be terminated when an error is encountered. More...
 
bool get_suppress_printing (const error_handler *err)
 Gets a logical value determining if printing of error and warning messages should be suppressed. More...
 
void set_suppress_printing (error_handler *err, bool x)
 Sets a logical value determining if printing of error and warning messages should be suppressed. More...
 
void get_error_message (const error_handler *err, char *msg, int *nmsg)
 Gets the current error message. More...
 
void get_warning_message (const error_handler *err, char *msg, int *nmsg)
 Gets the current warning message. More...
 
void get_error_fcn_name (const error_handler *err, char *fname, int *nfname)
 Gets the name of the function or subroutine that issued the last error message. More...
 
void get_warning_fcn_name (const error_handler *err, char *fname, int *nfname)
 Gets the name of the function or subroutine that issued the last warning message. More...
 
void report_error_with_callback (error_handler *err, const char *fname, const char *msg, int flag, error_callback cback, void *args)
 Reports an error condition to the user, and executes a callback routine. More...
 

Typedef Documentation

◆ error_callback

typedef void(* error_callback) (void *args)

Describes a function to call when an error is encountered.

Parameters
argsA pointer to any object to pass to the callback routine.

Definition at line 105 of file ferror.h.

Function Documentation

◆ alloc_error_handler()

void alloc_error_handler ( error_handler obj)

Initializes a new error handler object.

Parameters
objThe error_handler object to allocate.

◆ free_error_handler()

void free_error_handler ( error_handler obj)

Frees resources held by the error_handler object.

Parameters
objThe error_handler object.

◆ get_error_fcn_name()

void get_error_fcn_name ( const error_handler err,
char *  fname,
int *  nfname 
)

Gets the name of the function or subroutine that issued the last error message.

Parameters
errThe error_handler object.
fnameA character buffer where the name will be written.
nfnameOn input, the actual size of the buffer. On output, the actual number of characters written to fname (not including the null character).

◆ get_error_flag()

int get_error_flag ( const error_handler err)

Gets the current error flag.

Parameters
errThe error_handler object.
Returns
The current error flag.

◆ get_error_message()

void get_error_message ( const error_handler err,
char *  msg,
int *  nmsg 
)

Gets the current error message.

Parameters
errThe error_handler object.
msgA character buffer where the message will be written.
nmsgOn input, the actual size of the buffer. On output, the actual number of characters written to msg (not including the null character).

◆ get_exit_on_error()

bool get_exit_on_error ( const error_handler err)

Gets a logical value determining if the application should be terminated when an error is encountered.

Parameters
errThe error_handler object.
Returns
Returns true if the application should be terminated; else, false.

◆ get_log_filename()

void get_log_filename ( const error_handler err,
char *  fname,
int *  nfname 
)

Gets the name of the error log file.

Parameters
errThe error_handler object.
fnameA character buffer where the filename will be written. It is recommended that this be in the neighborhood of 256 elements.
nfnameOn input, the actual size of the buffer. Be sure to leave room for the null terminator character. On output, the actual numbers of characters written to fname (not including the null character).

◆ get_suppress_printing()

bool get_suppress_printing ( const error_handler err)

Gets a logical value determining if printing of error and warning messages should be suppressed.

Parameters
errThe error_handler object.
Returns
True if message printing should be suppressed; else, false to allow printing.

◆ get_warning_fcn_name()

void get_warning_fcn_name ( const error_handler err,
char *  fname,
int *  nfname 
)

Gets the name of the function or subroutine that issued the last warning message.

Parameters
errThe error_handler object.
fnameA character buffer where the name will be written.
nfnameOn input, the actual size of the buffer. On output, the actual number of characters written to fname (not including the null character).

◆ get_warning_flag()

int get_warning_flag ( const error_handler err)

Gets the current warning flag.

Parameters
errThe error_handler object.
Returns
The current warning flag.

◆ get_warning_message()

void get_warning_message ( const error_handler err,
char *  msg,
int *  nmsg 
)

Gets the current warning message.

Parameters
errThe error_handler object.
msgA character buffer where the message will be written.
nmsgOn input, the actual size of the buffer. On output, the actual number of characters written to msg (not including the null character).

◆ has_error_occurred()

bool has_error_occurred ( const error_handler err)

Tests to see if an error has been encountered.

Parameters
errThe error_handler object.
Returns
Returns true if an error has been encountered; else, false.

◆ has_warning_occurred()

bool has_warning_occurred ( const error_handler err)

Tests to see if a warning has been encountered.

Parameters
errThe error_handler object.
Returns
Returns true if a warning has been encountered; else, false.

◆ log_error()

void log_error ( const error_handler err,
const char *  fcn,
const char *  msg,
int  flag 
)

Writes an error log file.

Parameters
errThe error_handler object.
fcnThe name of the function or subroutine in which the error was encountered.
msgThe error message.
flagThe error flag.

◆ report_error()

void report_error ( error_handler err,
const char *  fcn,
const char *  msg,
int  flag 
)

Reports an error condition to the user.

Parameters
errThe error_handler object.
fcnThe name of the function or subroutine in which the error was encountered.
msgThe error message.
flagThe error flag.

◆ report_error_with_callback()

void report_error_with_callback ( error_handler err,
const char *  fname,
const char *  msg,
int  flag,
error_callback  cback,
void *  args 
)

Reports an error condition to the user, and executes a callback routine.

Parameters
errA pointer to the error handler object.
fnameThe name of the function or subroutine in which the error was encountered.
msgThe error message.
flagThe error flag.
cbackA pointer to the callback function.
argsA pointer to an object to pass to the callback function.

◆ report_warning()

void report_warning ( error_handler err,
const char *  fcn,
const char *  msg,
int  flag 
)

Reports a warning condition to the user.

Parameters
errThe error_handler object.
fcnThe name of the function or subroutine in which the warning was encountered.
msgThe warning message.
flagThe warning flag.

◆ reset_error_status()

void reset_error_status ( error_handler err)

Resets the error status flag to false, and the current error flag to zero.

Parameters
errThe error_handler object.

◆ reset_warning_status()

void reset_warning_status ( error_handler err)

Resets the warning status flag to false, and the current warning flag to zero.

Parameters
errThe error_handler object.

◆ set_exit_on_error()

void set_exit_on_error ( error_handler err,
bool  x 
)

Sets a logical value determining if the application should be terminated when an error is encountered.

Parameters
errA pointer to the error handler object.
[x]in Set to true if the application should be terminated when an error is reported; else, false.

◆ set_log_filename()

void set_log_filename ( error_handler err,
const char *  fname 
)

Sets the error log filename.

Parameters
errThe error_handler object.
fnameA null-terminated string containing the filename.

◆ set_suppress_printing()

void set_suppress_printing ( error_handler err,
bool  x 
)

Sets a logical value determining if printing of error and warning messages should be suppressed.

Parameters
errThe error_handler object.
xSet to true if message printing should be suppressed; else, false to allow printing.