[GRASS-dev] libgis: G_FATAL_EXIT|PRINT|RETURN

Martin Landa landa.martin at gmail.com
Sun Apr 7 02:21:01 PDT 2013


Hi,

2013/4/6 Markus Metz <markus.metz.giswork at gmail.com>:
>> These defines are used by a few functions, eg.
>> G_check_input_output_name(). Other candidates could eg.
>> Vect_open_old() and similar functions (eg. call G__error() when vector
>> map is not found). I would suggest to add G__error() and
>> G__set_error_code() just for internal use (see the attached path).
>
> What's your motivation for adding G__error() and G__set_error_code()?
> Are there problems with e.g. Vect_open_old()?

first of all, G_FATAL_EXIT|PRINT|RETURN codes exist in libgis for a
long time. Some functions use them as an argument. In raster library
Rast_open_old() calls G_fatal_error() when raster map is not found.
Currently Vect_open_old() calls G_warning() and return -1. Some vector
modules do not check return code of Vect_open_old(). My idea was to
call G__error() when vector map is not found. Then the program would
terminate if `err_code` in `error.c` is G_FATAL_EXIT. Otherwise
message would be printed out (G_FATAL_PRINT) or the function would
finish just with return code without printing any message
(G_FATAL_RETURN). Similarly to G_check_input_output(), adding
G__error() and G__set_error_code() would also avoid adding extra
arguments to these functions.

Martin

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa


More information about the grass-dev mailing list