[GRASS-dev] g.region error msg with empty WIND file
Markus Neteler
neteler at osgeo.org
Sat Aug 8 02:58:24 PDT 2015
Glynn,
On Fri, Aug 7, 2015 at 11:53 PM, Glynn Clements
<glynn at gclements.plus.com> wrote:
...
> But this won't catch the case where GRASS_REGION is being used, and it
> won't allow you to report *which* file is empty.
>From a user's perspective, the file info is quite important. So, yes,
the error message including the report about which file is empty would
be ideal.
> Catching it in G_get_element_window() would allow you to report the
> filename, but additionally won't catch calls from Rast_get_cellhd() to
> read the <mapset>/cellhd/<map> file.
>
> --- lib/gis/get_window.c (revision 65851)
> +++ lib/gis/get_window.c (working copy)
> @@ -118,6 +118,10 @@
> G_fatal_error(_("Unable to open element file <%s> for <%s@%s>"),
> element, name, mapset);
>
> + G_fseek(fp, 0, SEEK_END);
> + if (!G_ftell(fp))
> + G_fatal_error(_("Region file %s/%s/%s is empty"), mapset, element, name);
> + G_fseek(fp, 0, SEEK_SET);
> G__read_Cell_head(fp, window, 0);
> fclose(fp);
> }
Yes, such a message would solve this particular problem (we got it a
few times lately under heavy workload and unstable power supply).
> If you want to handle more of the cases while reporting the filename,
> G__read_Cell_head() and G__read_Cell_head_array() could be made to
> take the filename as an extra parameter so that it can be included in
> error messages.
I'm unsure if it is too much of a change? If only G__...() functions
are affected it should not count as an API change but still...
Markus
More information about the grass-dev
mailing list