[GRASS-dev] standard messages
Ivan Shmakov
oneingray at gmail.com
Thu Apr 9 09:24:23 EDT 2009
>>>>> Martin Landa <landa.martin at gmail.com> writes:
>> Oh, OK. Sorry for that. I will have a look at it now.
> another note, please use standardized messages [1], e.g. replace
> if ((infd = G_open_cell_old(qcchan, "")) < 0)
> G_fatal_error(_("Cannot open cell file [%s]"), qcchan);
> By
> "Unable to open raster map %s"
If there're standardized messages, why not to have them typed in
exactly once somewhere in the source?
The Unix Libc custom was to make the standard messages available
via the strerror () function, and to format the error message
like:
PROGRAM: OBJECT: STANDARD-MESSAGE
I. e., once the program gets into trouble, it may simply do:
G_fatal_error ("%s: %s: %s",
my_name, object, G_strerror (G_get_errno ()));
But even with the messages printed GRASS-way, it still seems to
be possible to do something like:
int
G_open_cell_old_or_fail (...)
{
int fd;
if ((fd = G_open_cell_old (...)) < 0)
G_fatal_error (_("Unable to open raster map %s"), ...);
return fd;
}
Given that the ``fail-if-cannot-open'' is the most common
behaviour of the GRASS modules, this approach will probably save
some lines of code as well.
> [1] http://grass.osgeo.org/wiki/Development_Specs#Standard_messages_sandbox
--
FSF associate member #7257
More information about the grass-dev
mailing list