Defines | Functions

error.c File Reference

GIS Library: Error messages functions. More...

#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 error.c:

Go to the source code of this file.

Defines

#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.

Detailed Description

GIS Library: Error messages functions.

(C) 1999-2008 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author:
USACERL and many others

Definition in file error.c.


Define Documentation

#define ERR   2

A fatal error message.

Definition at line 41 of file error.c.

Referenced by G_fatal_error().

#define MSG   0

A message.

Definition at line 29 of file 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 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:
msg string (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 error.c.

References ERR.

Referenced by 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_get_default_window(), G_get_ellipsoid_parameters(), G_get_raster_sample(), 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(), and G_read_color_rule().

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:
msg string (cannot be NULL)

Definition at line 119 of file error.c.

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

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 error.c.

References G_strcasecmp().

Referenced by G_percent2().

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

Print a message to stderr.

The output format depends on environment variable GRASS_MESSAGE_FORMAT

Parameters:
msg string (cannot be NULL)

Definition at line 74 of file error.c.

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

Referenced by G_done_msg(), and G_dump().

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_routine routine will be called like this: error_routine(msg, fatal)
Returns:
0

Definition at line 228 of file error.c.

int G_sleep_on_error ( int  flag  ) 

Turn on/off no_sleep flag.

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

Definition at line 210 of file error.c.

int G_suppress_warnings ( int  flag  ) 

Suppress printing a warning message to stderr.

Parameters:
flag a warning message will be suppressed if non-zero value is given
Returns:
previous flag

Definition at line 194 of file error.c.

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 error.c.

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:
msg string (cannot be NULL)

Definition at line 95 of file error.c.

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

int G_warning ( const char *  msg,
  ... 
)