GRASS Programmer's Manual  6.4.2(2012)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
lib/gis/error.c File Reference
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <stdarg.h>
#include <sys/types.h>
#include <grass/glocale.h>
#include <grass/gis.h>
Include dependency graph for lib/gis/error.c:

Go to the source code of this file.

Macros

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

Functions

void G_message (const char *msg,...)
 Print a message to stderr.
void G_verbose_message (const char *msg,...)
 Print a message to stderr but only if module is in verbose mode.
void G_important_message (const char *msg,...)
 Print a message to stderr even in brief mode (verbosity=1)
int G_fatal_error (const char *msg,...)
 Print a fatal error message to stderr.
int G_warning (const char *msg,...)
 Print a warning message to stderr.
int G_suppress_warnings (int flag)
 Suppress printing a warning message to stderr.
int G_sleep_on_error (int flag)
 Turn on/off no_sleep flag.
int 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.
int G_unset_error_routine (void)
 After this call subsequent error messages will be handled in the default method.
int G_info_format (void)
 Get current message format.

Macro Definition Documentation

#define ERR   2

A fatal error message.

Definition at line 41 of file lib/gis/error.c.

Referenced by G_fatal_error(), and V_call().

#define MSG   0

A message.

Definition at line 29 of file lib/gis/error.c.

Referenced by G_important_message(), G_message(), and G_verbose_message().

#define WARN   1

A warning message.

Definition at line 35 of file lib/gis/error.c.

Referenced by G_warning().

Function Documentation

int 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 150 of file lib/gis/error.c.

References ERR.

Referenced by Cairo_begin_scaled_raster(), Cairo_draw_bitmap(), Cairo_Graph_set(), class_apply_algorithm(), class_equiprob(), clean_dir(), D_cell_draw_setup(), D_parse_color(), D_popup(), D_setup(), db__copy_table(), db_select_CatValArray(), db_set_default_connection(), dig__read_head(), dig_area_add_isle(), dig_area_del_isle(), dig_del_area(), dig_del_isle(), dig_fwrite(), dig_load_plus(), dig_node_line_angle(), dig_Rd_Plus_head(), dig_Rd_spindx_head(), dig_read_cidx_head(), dig_spidx_del_area(), dig_spidx_del_isle(), dig_spidx_del_line(), dig_spidx_del_node(), dig_write_frmt_ascii(), E_edit_fp_cats(), F_open(), G3d_adjustRegion(), G3d_adjustRegionRes(), G3d_fatalError(), G3d_fatalError_noargs(), G__calloc(), G__gisinit(), G__ls(), G__make_mapset_element(), G__malloc(), G__no_gisinit(), G__realloc(), G_ask_ellipse_name(), G_ask_proj_name(), G_check_input_output_name(), G_fseek(), G_get_default_window(), G_get_ellipsoid_parameters(), G_get_raster_sample(), G_get_site(), G_get_window(), G_getenv(), G_getenv2(), G_home(), G_list(), G_location_path(), G_make_location(), G_make_mapset(), G_mapset(), G_put_map_row(), G_put_reclass(), G_put_site(), G_read_color_rule(), G_site_get_head(), G_site_new_struct(), G_site_put(), G_site_put_head(), G_sites_get_fields(), G_sites_open_old(), GK_print_keys(), Gp_load_sites(), GPJ__get_ellipsoid_params(), GS_load_att_map(), Gs_loadmap_as_bitmap(), Gs_loadmap_as_char(), Gs_loadmap_as_float(), Gs_loadmap_as_int(), Gs_loadmap_as_short(), I_list_groups(), I_list_subgroups(), IL_check_at_points_2d(), IL_create_bitmask(), IL_vector_input_data_2d(), LIB_main(), main(), make_mapset(), N_alloc_array_2d(), N_alloc_array_3d(), 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(), N_math_array_2d(), N_math_array_3d(), N_norm_array_2d(), N_norm_array_3d(), N_read_rast3d_to_array_3d(), N_read_rast_to_array_2d(), N_solver_gauss(), N_write_array_2d_to_rast(), N_write_array_3d_to_rast3d(), NetA_allpairs(), NetA_articulation_points(), NetA_betweenness_closeness(), NetA_compute_bridges(), NetA_eigenvector_centrality(), NetA_find_path(), NetA_flow(), NetA_get_node_costs(), NetA_init_timetable_from_db(), NetA_initialise_varray(), NetA_min_cut(), NetA_spanning_tree(), NetA_split_vertices(), NetA_strongly_connected_components(), NetA_weakly_connected_components(), Nviz_create_render_window(), pg_addedge(), pj_get_kv(), pj_get_string(), port_init(), PS_Graph_set(), R_parse_monitorcap(), read_bmp(), read_ellipsoid_table(), read_image(), read_pgm(), read_png(), read_ppm(), V1_open_old_ogr(), V2_delete_line_nat(), V2_open_old_ogr(), V2_read_line_nat(), V2_read_line_ogr(), V2_restore_line_nat(), Vect__open_old(), Vect_build_line_area(), Vect_build_ogr(), Vect_build_sidx_from_topo(), Vect_build_spatial_index(), Vect_cat_set(), Vect_check_input_output_name(), Vect_cidx_find_next(), Vect_cidx_get_cat_by_index(), Vect_cidx_get_field_number(), Vect_cidx_get_num_cats_by_index(), Vect_cidx_get_num_types_by_index(), Vect_cidx_get_num_unique_cats_by_index(), Vect_cidx_get_type_count_by_index(), Vect_copy(), Vect_copy_map_lines(), Vect_default_field_info(), Vect_delete_line(), Vect_get_area_boundaries(), Vect_get_area_centroid(), Vect_get_area_isle(), Vect_get_area_num_isles(), Vect_get_area_points(), Vect_get_centroid_area(), Vect_get_isle_area(), Vect_get_isle_boundaries(), Vect_get_isle_points(), Vect_get_line_areas(), Vect_get_line_nodes(), Vect_get_node_line(), Vect_get_node_line_angle(), Vect_get_node_n_lines(), Vect_graph_add_edge(), Vect_graph_build(), Vect_line_delete_point(), Vect_line_insert_point(), Vect_net_build_graph(), Vect_net_get_line_cost(), Vect_new_cats_struct(), Vect_new_line_struct(), Vect_overlay(), Vect_read_area_geos(), Vect_read_dblinks(), Vect_read_line(), Vect_read_line_geos(), Vect_remove_small_areas(), Vect_rename(), Vect_restore_line(), Vect_rewrite_line(), Vect_set_db_updated(), Vect_spatial_index_del_item(), Vect_write_line(), write_bmp(), write_image(), write_pgm(), write_png(), and write_ppm().

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

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

Ususally 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 119 of file lib/gis/error.c.

References G_verbose(), G_verbose_min(), and MSG.

Referenced by IL_vector_input_data_2d(), and Vect_build_nat().

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 487 of file lib/gis/error.c.

References G_strcasecmp(), and getenv().

Referenced by G_percent2(), and Vect_build_nat().

int 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
0

Definition at line 228 of file lib/gis/error.c.

Referenced by gui_modules.wxvdriver.DisplayDriver::__init__(), and gui_modules.wxnviz.Nviz::__init__().

int G_sleep_on_error ( int  flag)

Turn on/off no_sleep flag.

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

Definition at line 210 of file lib/gis/error.c.

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 194 of file lib/gis/error.c.

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

int 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 242 of file lib/gis/error.c.

Referenced by gui_modules.wxnviz.Nviz::__del__(), and gui_modules.wxvdriver.DisplayDriver::__del__().

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 95 of file lib/gis/error.c.

References G_verbose(), G_verbose_std(), and MSG.

Referenced by gsd_init_mpeg(), IL_vector_input_data_2d(), Vect_break_lines_list(), Vect_build_ogr(), Vect_build_partial(), and Vect_merge_lines().

int 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
0

Definition at line 173 of file lib/gis/error.c.

References WARN.

Referenced by check_symmetry(), class_equiprob(), clean_dir(), close_g3d_file(), db__copy_table(), db_delete_table(), db_get_column(), db_get_table_number_of_rows(), db_select_CatValArray(), db_select_int(), db_select_value(), db_start_driver_open_database(), db_table_exists(), db_table_to_sql(), dig__read_head(), dig_add_area(), dig_add_isle(), dig_cidx_del_cat(), dig_del_area(), dig_file_load(), dig_Rd_Plus_head(), dig_Rd_spindx_head(), dig_read_cidx_head(), dig_read_frmt_ascii(), dig_write_plus_file(), E_edit_cellhd(), err(), F_generate(), G3d_readCats(), G3d_readColors(), G3d_readRange(), G3d_readWindow(), G__check_for_auto_masking(), G__check_fp_type(), G__check_gisinit(), G__check_null_bit(), G__open_cell_old(), G__open_null_write(), G__quant_import(), G__random_d_initialize_0(), G__random_f_initialize_0(), G__raster_misc_read_line(), G__raster_misc_write_line(), G__read_row_ptrs(), G__write_fp_format(), G__write_null_bits(), G_adjust_Cell_head(), G_adjust_Cell_head3(), G_ask_colors(), G_ask_datum_name(), G_check_input_output_name(), G_command_history(), G_copy_file(), G_debug(), G_distance_point_to_line_segment(), G_get_3dview(), G_get_cellhd(), G_get_projinfo(), G_get_projunits(), G_get_reclass(), G_is_null_value(), G_open_cell_old(), G_parser(), G_put_3dview(), G_put_cell_title(), G_put_cellhd(), G_put_reclass(), G_quantize_fp_map(), G_quantize_fp_map_range(), G_raster_map_is_fp(), G_raster_map_type(), G_read_colors(), G_read_fp_range(), G_read_histogram(), G_read_history(), G_read_range(), G_read_raster_cats(), G_read_vector_cats(), G_round_fp_map(), G_set_fp_type(), G_set_null_value(), G_set_quant_rules(), G_set_window(), G_site_get(), G_site_get_head(), G_site_put_head(), G_sites_open_new(), G_system(), G_truncate_fp_map(), G_write_fp_range(), G_write_history(), G_write_quant(), G_write_range(), get_command(), gk_make_framesfromkeys(), gk_make_linear_framesfromkeys(), GK_update_frames(), Gp_load_sites(), Gp_set_color(), GPJ_ask_datum_params(), GPJ_get_datum_transform_by_name(), GPJ_grass_to_osr(), GPJ_osr_to_grass(), Gs_build_256lookup(), gs_err(), Gs_get_cat_label(), Gs_load_3dview(), GS_load_att_map(), Gs_loadmap_as_bitmap(), Gs_loadmap_as_char(), Gs_loadmap_as_float(), Gs_loadmap_as_int(), Gs_loadmap_as_short(), gs_malloc_lookup(), Gs_numtype(), Gs_pack_colors(), Gs_pack_colors_float(), gs_put_label(), GS_write_ppm(), GS_write_tif(), GS_write_zoom(), gsd_init_mpeg(), gsd_put_legend(), gsd_rot(), gsd_wall(), gsdrape_set_surface(), Gv_load_vect(), Gvl_load_colors_data(), I_fopen_group_file_append(), I_fopen_group_file_new(), I_fopen_group_file_old(), I_fopen_sigset_file_new(), I_fopen_sigset_file_old(), I_fopen_subgroup_file_append(), I_fopen_subgroup_file_new(), I_fopen_subgroup_file_old(), I_get_control_points(), I_get_target(), I_put_control_points(), IL_grid_calc_2d(), IL_interp_segments_2d(), IL_output_2d(), IL_vector_input_data_2d(), integration_test_gwflow(), integration_test_solute_transport(), LIB_main(), gui_modules.wxnviz.Nviz::LoadSurface(), gui_modules.wxnviz.Nviz::LoadVector(), gui_modules.wxnviz.Nviz::LoadVolume(), main(), N_les_pivot_create(), N_solver_bicgstab(), N_solver_cg(), N_solver_cholesky(), N_solver_gauss(), N_solver_jacobi(), N_solver_lu(), N_solver_pcg(), N_solver_SOR(), NetA_init_distinct(), NetA_init_timetable_from_db(), NetA_initialise_varray(), NetA_timetable_shortest_path(), Nviz_color_from_str(), Nviz_new_light(), Nviz_new_map_obj(), Nviz_set_focus_state(), open_g3d_file(), P_popmatrix(), P_pushmatrix(), parse_freetypecap(), pj_do_proj(), pj_do_transform(), pj_get_kv(), pj_get_string(), PNG_color(), process_command(), process_point(), PS_color(), read_coor(), read_datum_table(), read_ellipsoid_table(), read_file(), S_read(), segment_get_row(), segment_init(), segment_intersection_2d(), segment_intersection_2d_tol(), segment_pagein(), segment_pageout(), segment_put_row(), segment_seek(), segment_setup(), SimpleErrorMessage(), submit(), unit_test_arrays(), unit_test_assemble(), unit_test_geom_data(), unit_test_gradient(), unit_test_les_creation(), unit_test_solvers(), unit_test_tools(), V1_open_old_ogr(), V1_read_next_line_ogr(), V2_close_ogr(), V2_open_old_ogr(), Vect__open_old(), Vect__read_head(), Vect__write_head(), Vect_add_dblink(), Vect_build_line_area(), Vect_build_nat(), Vect_build_ogr(), Vect_check_input_output_name(), Vect_cidx_open(), Vect_cidx_save(), Vect_close(), Vect_coor_info(), Vect_copy(), Vect_copy_map_lines(), Vect_copy_table_by_cats(), Vect_copy_tables(), Vect_default_field_info(), Vect_delete(), Vect_get_area_points(), Vect_get_area_points_geos(), Vect_get_dblink(), Vect_get_point_in_poly(), Vect_graph_shortest_path(), Vect_isle_find_area(), Vect_legal_filename(), Vect_level(), Vect_line_check_intersection(), Vect_line_segment(), Vect_map_add_dblink(), Vect_map_del_dblink(), Vect_merge_lines(), Vect_net_build_graph(), Vect_net_shortest_path(), Vect_open_new(), Vect_open_topo(), Vect_overlay_and(), Vect_read_dblinks(), Vect_rename(), Vect_save_spatial_index(), Vect_save_topo(), Vect_segment_intersection(), Vect_set_open_level(), Vect_set_varray_from_cat_list(), Vect_set_varray_from_cat_string(), Vect_set_varray_from_db(), Vect_str_to_cat_list(), Vect_write_dblinks(), and Vedit_modify_cats().