Error-Reporting.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <html lang="en">
  2. <head>
  3. <title>Error Reporting - avram - a virtual machine code interpreter</title>
  4. <meta http-equiv="Content-Type" content="text/html">
  5. <meta name="description" content="avram - a virtual machine code interpreter">
  6. <meta name="generator" content="makeinfo 4.13">
  7. <link title="Top" rel="start" href="index.html#Top">
  8. <link rel="up" href="Library-Reference.html#Library-Reference" title="Library Reference">
  9. <link rel="prev" href="Version-Management.html#Version-Management" title="Version Management">
  10. <link rel="next" href="Profiling.html#Profiling" title="Profiling">
  11. <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
  12. <meta http-equiv="Content-Style-Type" content="text/css">
  13. <style type="text/css"><!--
  14. pre.display { font-family:inherit }
  15. pre.format { font-family:inherit }
  16. pre.smalldisplay { font-family:inherit; font-size:smaller }
  17. pre.smallformat { font-family:inherit; font-size:smaller }
  18. pre.smallexample { font-size:smaller }
  19. pre.smalllisp { font-size:smaller }
  20. span.sc { font-variant:small-caps }
  21. span.roman { font-family:serif; font-weight:normal; }
  22. span.sansserif { font-family:sans-serif; font-weight:normal; }
  23. --></style>
  24. </head>
  25. <body>
  26. <div class="node">
  27. <a name="Error-Reporting"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="Profiling.html#Profiling">Profiling</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="Version-Management.html#Version-Management">Version Management</a>,
  31. Up:&nbsp;<a rel="up" accesskey="u" href="Library-Reference.html#Library-Reference">Library Reference</a>
  32. <hr>
  33. </div>
  34. <h3 class="section">3.6 Error Reporting</h3>
  35. <p><a name="index-error-messages-606"></a>Most of the error reporting by other functions in the library is done by
  36. way of the functions declared in <samp><span class="file">error.h</span></samp>. These function
  37. communicate directly with the user through standard error. Client
  38. programs should also use these functions where possible for the sake of
  39. a uniform interface.
  40. <div class="defun">
  41. &mdash; Function: void <b>avm_set_program_name</b> (<var>char *argv0</var>)<var><a name="index-avm_005fset_005fprogram_005fname-607"></a></var><br>
  42. <blockquote><p>The argument to this function should be the address of a null terminated
  43. string holding the name of the program to be reported in error messages
  44. that begin with a program name. Typically this string will be the name
  45. of the program as it was invoked on the command line, possibly with path
  46. components stripped from it. An alternative would be to set it to the
  47. name of a virtual code application being evaluated. If this function is
  48. never called, the name <code>"avram"</code> is used by default. Space for a
  49. copy of the program name is allocated by this function, and a fatal
  50. memory overflow error is possible if there is insufficient space available.
  51. </p></blockquote></div>
  52. <div class="defun">
  53. &mdash; Function: char* <b>avm_program_name</b> ()<var><a name="index-avm_005fprogram_005fname-608"></a></var><br>
  54. <blockquote><p>This function returns a pointer to a null terminated character string
  55. holding the program name presently in use. It will be either the name
  56. most recently set by <code>avm_set_program_name</code>, or the default name
  57. <code>"avram"</code> if none has been set. The string whose address is
  58. returned should not be modified by the caller.
  59. </p></blockquote></div>
  60. <div class="defun">
  61. &mdash; Function: void <b>avm_warning</b> (<var>char *message</var>)<var><a name="index-avm_005fwarning-609"></a></var><br>
  62. <blockquote><p>This function writes the null terminated string whose address is given
  63. to standard error, prefaced by the program name and followed by a line
  64. break.
  65. </p></blockquote></div>
  66. <div class="defun">
  67. &mdash; Function: void <b>avm_error</b> (<var>char *message</var>)<var><a name="index-avm_005ferror-610"></a></var><br>
  68. <blockquote><p>This function writes the null terminated string whose address is given
  69. to standard error, prefaced by the program name and followed by a line
  70. break, as <code>avm_warning</code>, but it then terminates the process with an
  71. exit code of 1.
  72. </p></blockquote></div>
  73. <div class="defun">
  74. &mdash; Function: void <b>avm_fatal_io_error</b> (<var>char *message, char *filename, int reason</var>)<var><a name="index-avm_005ffatal_005fio_005ferror-611"></a></var><br>
  75. <blockquote><p>This function is useful for reporting errors caused in the course of
  76. reading or writing files. The message is written to standard error
  77. prefaced by the program name, and incorporating the name of the relevant
  78. file. The <var>reason</var> should be the error code obtained from the
  79. standard <code>errno</code> variable, which will be translated to an
  80. <a name="index-g_t_0040code_007bstrerror_007d-612"></a>informative message if possible by the standard <code>strerror</code> function
  81. and appended to the message. After the message is written, the process
  82. will terminate with an exit code of 1.
  83. </p></blockquote></div>
  84. <div class="defun">
  85. &mdash; Function: void <b>avm_non_fatal_io_error</b> (<var>char *message, char *filename, int reason</var>)<var><a name="index-avm_005fnon_005ffatal_005fio_005ferror-613"></a></var><br>
  86. <blockquote><p>This function does the same as <code>avm_fatal_io_error</code> except that it
  87. doesn't exit the program, and allows control to return to the caller,
  88. which should take appropriate action.
  89. </p></blockquote></div>
  90. <div class="defun">
  91. &mdash; Function: void <b>avm_internal_error</b> (<var>int code</var>)<var><a name="index-avm_005finternal_005ferror-614"></a></var><br>
  92. <blockquote><p>This function is used to report internal errors and halt the
  93. program. The error message is written to standard error prefaced by the
  94. program name and followed by a line break. The code should be a unique
  95. integer constant (i.e., not one that's used for any other internal
  96. error), that will be printed as part of the error message as an aid to
  97. the maintainer.
  98. <p>This function should be used by client programs only in the event of
  99. conditions that constitute some violation of a required invariant. It
  100. indicates to the user that something has gone wrong with the program,
  101. for which a bug report would be appropriate.
  102. </p></blockquote></div>
  103. <div class="defun">
  104. &mdash; Function: void <b>avm_reclamation_failure</b> (<var>char *entity, counter count</var>)<var><a name="index-avm_005freclamation_005ffailure-615"></a></var><br>
  105. <blockquote><p>This function is used only by the <code>avm_count</code> functions to report
  106. unreclaimed storage. The <var>count</var> is the number of units of
  107. storage left unreclaimed, and the <var>entity</var> is the address of
  108. a null terminated string describing the type of unreclaimed entity, such
  109. as <code>"lists"</code> or <code>"branches"</code>. The message is written to
  110. standard error followed by a line break, but the program is not halted
  111. and control returns to the caller.
  112. </p></blockquote></div>
  113. </body></html>