GRASS GIS 7 Programmer's Manual  7.9.dev(2019)-f6edaaffa
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_xid(), cairo_write_bmp(), cairo_write_ppm(), cairo_write_xid(), clean_dir(), db_set_default_connection(), dig__read_head(), dig_area_del_isle(), dig_fwrite(), dig_load_plus(), dig_node_line_angle(), dig_Rd_Plus_head(), dig_Rd_spidx_head(), dig_read_cidx_head(), dig_spidx_del_area(), dig_spidx_del_isle(), dig_spidx_del_node(), dig_Wr_spidx_head(), G_adjust_Cell_head(), G_adjust_Cell_head3(), G_adjust_window_ll(), 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_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_zstd_compress_bound(), GK_print_keys(), GPJ_init_transform(), IL_create_bitmask(), IL_write_temp_2d(), M_do_list(), M_do_remove(), main(), N_assemble_les_2d_param(), N_assemble_les_3d_param(), 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(), NetA_betweenness_closeness(), NetA_flow(), NetA_initialise_varray(), NetA_min_cut(), NetA_strongly_connected_components(), NetA_weakly_connected_components(), pg_addedge(), port_init(), Rast3d_fatal_error_noargs(), Rast__check_fp_type(), Rast__check_null_bit(), Rast__null_bitstream_size(), Rast__open_null_write(), Rast__open_old(), Rast_close(), Rast_get_cellhd(), Rast_get_vrt(), Rast_map_is_fp(), Rast_map_type(), Rast_option_to_interp_type(), Rast_put_cellhd(), Rast_put_reclass(), Rast_quantize_fp_map(), Rast_read_histogram(), Rast_set_fp_type(), Rast_set_quant_rules(), Rast_unopen(), Rast_window_cols(), Rast_window_rows(), Rast_write_fp_range(), Rast_write_history(), Rast_write_quant(), Rast_write_range(), Rast_write_rstats(), read_image(), RTreeWriteBranch(), RTreeWriteNode(), seg_seek_fast(), seg_seek_slow(), V1_close_nat(), V1_close_ogr(), V1_close_pg(), V1_delete_line_ogr(), V1_delete_line_pg(), V1_open_new_ogr(), V1_open_new_pg(), V1_open_old_ogr(), V1_open_old_pg(), V1_read_next_line_pg(), V1_rewind_ogr(), V1_rewind_pg(), V2__write_area_sfa(), V2_close_ogr(), V2_close_pg(), V2_open_old_ogr(), V2_open_old_pg(), V2_rewind_ogr(), V2_rewind_pg(), Vect__get_area_points(), Vect__open_topo_pg(), Vect_build_line_area(), Vect_build_ogr(), Vect_build_partial(), Vect_build_pg(), Vect_build_sidx(), Vect_cat_set(), Vect_cats_set_constraint(), Vect_copy(), Vect_get_area_centroid(), Vect_get_area_isle(), Vect_get_area_num_isles(), Vect_get_isle_area(), Vect_get_isle_points(), Vect_graph_add_edge(), Vect_graph_build(), Vect_new_line_struct(), Vect_new_map_struct(), Vect_open_fidx(), Vect_overlay(), Vect_save_fidx(), Vect_save_frmt(), Vect_set_db_updated(), Vect_sfa_get_num_features(), Vect_spatial_index_del_item(), 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().

◆ 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_math_solver_sparse_gs(), G_math_solver_sparse_jacobi(), G_matrix_print(), I_compute_georef_equations_tps(), IL_create_bitmask(), M_do_copy(), M_do_remove(), M_do_rename(), show_colormode(), Vect_build_ogr(), Vect_build_partial(), and Vect_build_pg().

◆ 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.

Referenced by I_get_group(), I_get_group_title(), I_get_subgroup(), and I_get_target().

◆ 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(), PNG_Graph_set(), Vect_cats_set_constraint(), and Vect_save_frmt().

◆ G_warning()

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

Print a warning message to stderr.

The output format depends on environment variable GRASS_MESSAGE_FORMAT

A warning message can be suppressed by G_suppress_warnings()

Parameters
msgstring (cannot be NULL)
Returns

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

Referenced by clean_dir(), close_g3d_file(), db_delete_table(), db_get_table_number_of_rows(), db_start_driver_open_database(), dig__read_head(), dig_out_of_memory(), dig_Rd_Plus_head(), dig_Rd_spidx_head(), dig_read_cidx_head(), dig_read_frmt_ascii(), dig_write_plus_file(), fopen_group_file_old(), fopen_subgroup_file_old(), G__matrix_add(), G_copy_file(), G_get_projinfo(), G_get_projunits(), G_matrix_init(), G_matrix_inverse(), G_matrix_LU_solve(), G_matrix_product(), G_matrix_read(), G_matrix_scalar_mul(), G_matrix_set_element(), G_matvect_extract_vector(), G_matvect_get_column(), G_matvect_get_row(), G_parser(), G_put_3dview(), G_read_compressed(), G_read_vector_timestamp(), G_vector_copy(), G_vector_init(), G_vector_norm1(), G_vector_product(), G_vector_sub(), G_write_vector_timestamp(), gk_make_linear_framesfromkeys(), GP_str_to_marker(), GPJ__get_datum_params(), GPJ_init_transform(), GPJ_osr_to_grass(), gs_err(), Gs_load_3dview(), gs_malloc_lookup(), GS_write_ppm(), GS_write_tif(), GS_write_zoom(), gsd_put_legend(), gsd_rot(), I_cluster_exec(), I_create_cat_rast(), I_fopen_group_file_append(), I_fopen_group_file_new(), I_fopen_sigset_file_new(), I_fopen_subgroup_file_append(), I_fopen_subgroup_file_new(), I_get_control_points(), I_get_target(), I_iclass_analysis(), I_iclass_init_group(), I_iclass_statistics_get_histo(), I_iclass_statistics_get_max(), I_iclass_statistics_get_mean(), I_iclass_statistics_get_min(), I_iclass_statistics_get_product(), I_iclass_statistics_get_range_max(), I_iclass_statistics_get_range_min(), I_iclass_statistics_get_stddev(), I_iclass_statistics_get_sum(), I_put_control_points(), M_do_copy(), M_do_remove(), M_do_rename(), main(), NetA_distance_to_points(), NetA_initialise_varray(), NetA_strongly_connected_components(), NetA_timetable_shortest_path(), NetA_weakly_connected_components(), Nviz_color_from_str(), Nviz_make_current_render_window(), Nviz_set_focus_state(), P_Create_Aux2_Table(), P_Create_Aux4_Table(), P_popmatrix(), P_pushmatrix(), parse_fontcap(), Rast3d_read_range(), Rast3d_rewrite_header(), Rast3d_write_colors(), Rast__check_for_auto_masking(), Rast__check_fp_type(), Rast__error_handler(), Rast__quant_import(), Rast_close_gdal_write_link(), Rast_is_null_value(), Rast_read_fp_range(), Rast_read_histogram(), Rast_read_history(), Rast_read_range(), Rast_set_null_value(), Rast_write_quant(), rbtree_create(), Rowio_setup(), seg_pageout(), seg_setup(), Segment_init(), Segment_put(), SimpleErrorMessage(), V1_close_pg(), V1_delete_line_ogr(), V1_delete_line_pg(), V1_open_new_ogr(), V1_open_new_pg(), V1_open_old_nat(), V1_open_old_pg(), V2__write_area_sfa(), V2_close_ogr(), V2_close_pg(), V2_open_old_ogr(), V2_open_old_pg(), Vect__open_topo_pg(), Vect__read_head(), Vect__write_head(), Vect_area_alive(), Vect_build_line_area(), Vect_build_ogr(), Vect_build_pg(), Vect_build_sidx_from_topo(), Vect_cats_in_constraint(), Vect_cats_set_constraint(), Vect_cidx_open(), Vect_close(), Vect_coor_info(), Vect_copy(), Vect_copy_map_dblinks(), Vect_fidx_dump(), Vect_get_area_box(), Vect_get_area_points(), Vect_get_area_points_geos(), Vect_get_dblink(), Vect_get_finfo_dsn_name(), Vect_get_finfo_format_info(), Vect_get_finfo_geometry_type(), Vect_get_finfo_layer_name(), Vect_get_finfo_topology_info(), Vect_get_isle_box(), Vect_get_isle_points(), Vect_get_next_line_id(), Vect_get_node_coor(), Vect_isle_alive(), Vect_level(), Vect_map_del_dblink(), Vect_node_alive(), Vect_open_fidx(), Vect_open_topo(), Vect_read_ascii_head(), Vect_read_next_line(), Vect_save_fidx(), Vect_save_frmt(), Vect_save_sidx(), Vect_save_topo(), Vect_set_constraint_field(), Vect_sfa_get_num_features(), Vect_write_dblinks(), vector2perimeters(), and Vedit_delete_area_centroid().