GRASS GIS 8 Programmer's Manual  8.2.1(2023)-exported
gis/error.c File Reference

GIS Library - Error messages functions. More...

#include <stdlib.h>
#include <string.h>
#include <setjmp.h>
#include <unistd.h>
#include <time.h>
#include <stdarg.h>
#include <sys/types.h>
#include <grass/glocale.h>
#include <grass/gis.h>
#include "gis_local_proto.h"
Include dependency graph for gis/error.c:

Go to the source code of this file.

Macros

#define MSG   0
 A message. More...
 
#define WARN   1
 A warning message. More...
 
#define ERR   2
 A fatal error message. More...
 

Functions

jmp_buf * G_fatal_longjmp (int enable)
 
void G_message (const char *msg,...)
 Print a message to stderr. More...
 
void G_verbose_message (const char *msg,...)
 Print a message to stderr but only if module is in verbose mode. More...
 
void G_important_message (const char *msg,...)
 Print a message to stderr even in brief mode (verbosity=1) More...
 
void G_fatal_error (const char *msg,...)
 Print a fatal error message to stderr. More...
 
void G_warning (const char *msg,...)
 Print a warning message to stderr. More...
 
int G_suppress_warnings (int flag)
 Suppress printing a warning message to stderr. More...
 
int G_sleep_on_error (int flag)
 Turn on/off no_sleep flag. More...
 
void G_set_error_routine (int(*error_routine)(const char *, int))
 Establishes error_routine as the routine that will handle the printing of subsequent error messages. More...
 
void G_unset_error_routine (void)
 After this call subsequent error messages will be handled in the default method. More...
 
void G_init_logging (void)
 
int G_info_format (void)
 Get current message format. More...
 

Detailed Description

GIS Library - Error messages functions.

(C) 1999-2011 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
USACERL and many others

Definition in file gis/error.c.

Macro Definition Documentation

◆ ERR

#define ERR   2

A fatal error message.

Definition at line 44 of file gis/error.c.

◆ MSG

#define MSG   0

A message.

Definition at line 32 of file gis/error.c.

◆ WARN

#define WARN   1

A warning message.

Definition at line 38 of file gis/error.c.

Function Documentation

◆ G_fatal_error()

void G_fatal_error ( const char *  msg,
  ... 
)

Print a fatal error message to stderr.

The output format depends on environment variable GRASS_MESSAGE_FORMAT

By default, the message is handled by an internal routine which prints the message to the screen. Using G_set_error_routine() the programmer can have the message handled by another routine. This is especially useful if the message should go to a particular location on the screen when using curses or to a location on a graphics device (monitor).

Parameters
msgstring (cannot be NULL)
Returns
Terminates with an exit status of EXIT_FAILURE if no external routine is specified by G_set_error_routine()

Definition at line 160 of file gis/error.c.

References G_verbose().

Referenced by AS_option_to_algorithm(), Cairo_Graph_set(), cairo_read_bmp(), cairo_read_ppm(), cairo_read_xid(), cairo_write_bmp(), cairo_write_ppm(), cairo_write_xid(), check_create_import_opts(), clean_dir(), G__read_gisrc_path(), G_adjust_Cell_head(), G_adjust_Cell_head3(), G_adjust_window_ll(), G_check_input_output_name(), G_config_path(), G_fseek(), G_getenv(), G_getenv2(), G_home(), G_list(), G_location_path(), G_ls2(), G_make_mapset(), G_mapset(), G_mapset_path(), G_math_cholesky_sband_decomposition(), G_math_solver_pcg_sband(), G_open_option_file(), G_option_to_separator(), G_owner(), G_read_key_value_file(), G_srand48_auto(), G_vector_norm_euclid(), G_vector_norm_maxval(), G_write_key_value_file(), G_write_projsrid(), G_write_projwkt(), G_zstd_compress_bound(), GK_print_keys(), GPJ_init_transform(), IL_create_bitmask(), IL_interp_segments_2d_parallel(), IL_write_temp_2d(), M_do_list(), M_do_remove(), main(), N_compute_gradient_field_2d(), N_compute_gradient_field_3d(), N_compute_gradient_field_components_2d(), N_compute_gradient_field_components_3d(), N_copy_array_2d(), N_copy_array_3d(), N_write_array_2d_to_rast(), P_Sparse_Points(), read_bmp(), read_image(), read_pgm(), read_ppm(), seg_seek_fast(), seg_seek_slow(), write_bmp(), write_image(), write_pgm(), and write_ppm().

◆ G_fatal_longjmp()

jmp_buf* G_fatal_longjmp ( int  enable)

Definition at line 67 of file gis/error.c.

◆ G_important_message()

void G_important_message ( const char *  msg,
  ... 
)

Print a message to stderr even in brief mode (verbosity=1)

Usually just G_percent()/G_clicker() would be shown at this level. This allows important non-error/warning messages to display as well.

The output format depends on environment variables GRASS_MESSAGE_FORMAT and GRASS_VERBOSE

Parameters
msgstring (cannot be NULL)

Definition at line 131 of file gis/error.c.

References G_verbose(), and G_verbose_min().

Referenced by GPJ_init_transform().

◆ G_info_format()

int G_info_format ( void  )

Get current message format.

Maybe set to either "standard" or "gui" (normally GRASS takes care)

Returns
grass_info_format value

Definition at line 532 of file gis/error.c.

References G_init_logging().

◆ G_init_logging()

void G_init_logging ( void  )

Definition at line 351 of file gis/error.c.

Referenced by G_info_format(), and G_init_all().

◆ G_message()

void G_message ( const char *  msg,
  ... 
)

Print a message to stderr.

The output format depends on environment variable GRASS_MESSAGE_FORMAT

Parameters
msgstring (cannot be NULL)

Definition at line 90 of file gis/error.c.

References G_verbose(), and G_verbose_std().

Referenced by G_done_msg(), G_math_solver_cholesky(), G_math_solver_gauss(), G_math_solver_gs(), G_math_solver_jacobi(), G_math_solver_sparse_gs(), G_math_solver_sparse_jacobi(), G_matrix_print(), IL_create_bitmask(), M_do_copy(), M_do_remove(), M_do_rename(), N_write_array_2d_to_rast(), and show_colormode().

◆ G_set_error_routine()

void G_set_error_routine ( int(*)(const char *, int)  error_routine)

Establishes error_routine as the routine that will handle the printing of subsequent error messages.

Parameters
error_routineroutine will be called like this: error_routine(msg, fatal)
Returns

Definition at line 261 of file gis/error.c.

◆ G_sleep_on_error()

int G_sleep_on_error ( int  flag)

Turn on/off no_sleep flag.

If flag is 0, then no pause will occur after printing an error or warning message. Otherwise the pause will occur.

Parameters
flagif non-zero/zero value is given G_sleep() will be activated/deactivated
Returns
previous no_sleep value

Definition at line 243 of file gis/error.c.

◆ G_suppress_warnings()

int G_suppress_warnings ( int  flag)

Suppress printing a warning message to stderr.

Parameters
flaga warning message will be suppressed if non-zero value is given
Returns
previous flag

Definition at line 223 of file gis/error.c.

◆ G_unset_error_routine()

void G_unset_error_routine ( void  )

After this call subsequent error messages will be handled in the default method.

Error messages are printed directly to the screen: ERROR: message or WARNING: message

Returns
0

Definition at line 274 of file gis/error.c.

◆ G_verbose_message()

void G_verbose_message ( const char *  msg,
  ... 
)

Print a message to stderr but only if module is in verbose mode.

The output format depends on environment variables GRASS_MESSAGE_FORMAT and GRASS_VERBOSE

Parameters
msgstring (cannot be NULL)

Definition at line 109 of file gis/error.c.

References G_verbose(), and G_verbose_std().

Referenced by M_do_copy(), M_do_remove(), M_do_rename(), and PNG_Graph_set().

◆ G_warning()

void G_warning ( const char *  msg,
  ... 
)