error.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <sys/types.h>
  4. #include <unistd.h>
  5. #include <time.h>
  6. #include <stdarg.h>
  7. #include <grass/gis.h>
  8. #include "raster3d_intern.h"
  9. /*---------------------------------------------------------------------------*/
  10. /*!
  11. * \brief This function ignores the error.
  12. *
  13. * \param msg
  14. * \return void
  15. */
  16. void Rast3d_skip_error(const char *msg)
  17. {
  18. }
  19. /*!
  20. * \brief Prints error message
  21. *
  22. * This function prints the
  23. * error message <em>msg</em> to <em>stderr</em> and returns.
  24. *
  25. * \param msg
  26. * \return void
  27. */
  28. void Rast3d_print_error(const char *msg)
  29. {
  30. fprintf(stderr, "ERROR: ");
  31. fprintf(stderr, "%s", msg);
  32. fprintf(stderr, "\n");
  33. }
  34. /*!
  35. * \brief Prints fatal error message
  36. *
  37. * This function prints the fatal
  38. * error message <em>msg</em>, and terminates the program with an error status.
  39. *
  40. * \param msg
  41. * \return void
  42. */
  43. void Rast3d_fatal_error(const char *msg, ...)
  44. {
  45. char buffer[2000]; /* No novels to the error logs, OK? */
  46. va_list ap;
  47. va_start(ap, msg);
  48. vsprintf(buffer, msg, ap);
  49. va_end(ap);
  50. G_fatal_error("%s", buffer);
  51. }
  52. void Rast3d_fatal_error_noargs(const char *msg)
  53. {
  54. G_fatal_error("%s", msg);
  55. }
  56. void Rast3d_error(const char *msg, ...)
  57. {
  58. char buffer[2000]; /* No novels to the error logs, OK? */
  59. va_list ap;
  60. va_start(ap, msg);
  61. vsprintf(buffer, msg, ap);
  62. va_end(ap);
  63. (*g3d_error_fun) (buffer);
  64. }