[GRASS-git] [OSGeo/grass] e2ba42: libgis: Mention session in the variable not set me...

Vaclav Petras noreply at github.com
Thu Jan 27 06:45:06 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: e2ba426d8cdefc0b56645494c3c1541cb535ee64
      https://github.com/OSGeo/grass/commit/e2ba426d8cdefc0b56645494c3c1541cb535ee64
  Author: Vaclav Petras <wenzeslaus at gmail.com>
  Date:   2022-01-27 (Thu, 27 Jan 2022)

  Changed paths:
    M lib/gis/env.c

  Log Message:
  -----------
  libgis: Mention session in the variable not set message (#2130)

This changes the message in _G_getenv_ and _G_getenv2_ to say "Incomplete GRASS session" in the first place and then say that the variable is not set, e.g., `Incomplete GRASS session: Variable 'LOCATION_NAME' not set`. It uses _incomplete_ rather than _corrupted_ because it is more general.

Unfortunately, there is not much information readily available in the code to enhance the message so that the user has more information. The variable may not be set as the message says, but chances are, the session has ended and the process is dangling and reading a deleted session (GISRC) file. To obtain the information, we would have to actually run more code because the underlying _read_env_ function does not consider a missing file to be an error (that's correct for the mapset var file, i.e., `loc == G_VAR_MAPSET`).

In general there are might be many reasons why variable is missing. However, optional variables should be read with the no-fatal versions of these functions (_G_getenv_nofatal_ and _G_getenv_nofatal2_), so the functions producing a fatal error (_G_getenv_ and _G_getenv2_) are likely used for some session-critical variables. Hence, focusing in the session in the error message.

The same message is there twice because there are two similar functions which are already contain duplicate code.




More information about the grass-commit mailing list