/3rd-party/glib-2.16.6/docs/reference/glib/html/glib-Error-Reporting.html

https://bitbucket.org/super119/plu2youku · HTML · 814 lines · 785 code · 29 blank · 0 comment · 0 complexity · abb6c10b6fae80e6d6a7f4e9a79c88fb MD5 · raw file

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <title>Error Reporting</title>
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
  7. <link rel="home" href="index.html" title="GLib Reference Manual">
  8. <link rel="up" href="glib-core.html" title="GLib Core Application Support">
  9. <link rel="prev" href="glib-IO-Channels.html" title="IO Channels">
  10. <link rel="next" href="glib-Warnings-and-Assertions.html" title="Message Output and Debugging Functions">
  11. <meta name="generator" content="GTK-Doc V1.10 (XML mode)">
  12. <link rel="stylesheet" href="style.css" type="text/css">
  13. <link rel="chapter" href="glib.html" title="GLib Overview">
  14. <link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
  15. <link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
  16. <link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
  17. <link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
  18. <link rel="chapter" href="tools.html" title="GLib Tools">
  19. <link rel="index" href="ix01.html" title="Index">
  20. <link rel="index" href="ix02.html" title="Index of deprecated symbols">
  21. <link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
  22. <link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
  23. <link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
  24. <link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
  25. <link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
  26. <link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
  27. <link rel="index" href="ix09.html" title="Index of new symbols in 2.14">
  28. <link rel="index" href="ix10.html" title="Index of new symbols in 2.16">
  29. </head>
  30. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  31. <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
  32. <tr valign="middle">
  33. <td><a accesskey="p" href="glib-IO-Channels.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
  34. <td><a accesskey="u" href="glib-core.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
  35. <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
  36. <th width="100%" align="center">GLib Reference Manual</th>
  37. <td><a accesskey="n" href="glib-Warnings-and-Assertions.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
  38. </tr>
  39. <tr><td colspan="5" class="shortcuts"><nobr><a href="#glib-Error-Reporting.synopsis" class="shortcut">Top</a>
  40.  | 
  41. <a href="#glib-Error-Reporting.description" class="shortcut">Description</a></nobr></td></tr>
  42. </table>
  43. <div class="refentry" lang="en">
  44. <a name="glib-Error-Reporting"></a><div class="titlepage"></div>
  45. <div class="refnamediv"><table width="100%"><tr>
  46. <td valign="top">
  47. <h2><span class="refentrytitle"><a name="glib-Error-Reporting.top_of_page"></a>Error Reporting</span></h2>
  48. <p>Error Reporting a system for reporting errors</p>
  49. </td>
  50. <td valign="top" align="right"></td>
  51. </tr></table></div>
  52. <div class="refsynopsisdiv">
  53. <a name="glib-Error-Reporting.synopsis"></a><h2>Synopsis</h2>
  54. <pre class="synopsis">
  55. #include &lt;glib.h&gt;
  56. <a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a>;
  57. <a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a>* <a class="link" href="glib-Error-Reporting.html#g-error-new" title="g_error_new ()">g_error_new</a> (<a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> domain,
  58. <a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> code,
  59. const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *format,
  60. ...);
  61. <a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a>* <a class="link" href="glib-Error-Reporting.html#g-error-new-literal" title="g_error_new_literal ()">g_error_new_literal</a> (<a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> domain,
  62. <a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> code,
  63. const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *message);
  64. void <a class="link" href="glib-Error-Reporting.html#g-error-free" title="g_error_free ()">g_error_free</a> (<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> *error);
  65. <a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a>* <a class="link" href="glib-Error-Reporting.html#g-error-copy" title="g_error_copy ()">g_error_copy</a> (const <a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> *error);
  66. <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> <a class="link" href="glib-Error-Reporting.html#g-error-matches" title="g_error_matches ()">g_error_matches</a> (const <a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> *error,
  67. <a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> domain,
  68. <a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> code);
  69. void <a class="link" href="glib-Error-Reporting.html#g-set-error" title="g_set_error ()">g_set_error</a> (<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **err,
  70. <a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> domain,
  71. <a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> code,
  72. const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *format,
  73. ...);
  74. void <a class="link" href="glib-Error-Reporting.html#g-propagate-error" title="g_propagate_error ()">g_propagate_error</a> (<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **dest,
  75. <a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> *src);
  76. void <a class="link" href="glib-Error-Reporting.html#g-clear-error" title="g_clear_error ()">g_clear_error</a> (<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **err);
  77. void <a class="link" href="glib-Error-Reporting.html#g-prefix-error" title="g_prefix_error ()">g_prefix_error</a> (<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **err,
  78. const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *format,
  79. ...);
  80. void <a class="link" href="glib-Error-Reporting.html#g-propagate-prefixed-error" title="g_propagate_prefixed_error ()">g_propagate_prefixed_error</a> (<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **dest,
  81. <a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> *src,
  82. const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *format,
  83. ...);
  84. </pre>
  85. </div>
  86. <div class="refsect1" lang="en">
  87. <a name="glib-Error-Reporting.description"></a><h2>Description</h2>
  88. <p>
  89. GLib provides a standard method of reporting errors from a called function to
  90. the calling code. (This is the same problem solved by exceptions in other
  91. languages.) It's important to understand that this method is both a
  92. <span class="emphasis"><em>data type</em></span> (the <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> object) and a <span class="emphasis"><em>set of
  93. rules.</em></span> If you use <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> incorrectly, then your code will not
  94. properly interoperate with other code that uses <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>, and users of your API
  95. will probably get confused.
  96. </p>
  97. <p>
  98. First and foremost: <span class="emphasis"><em><a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> should only be used to report
  99. recoverable runtime errors, never to report programming errors.</em></span> If
  100. the programmer has screwed up, then you should use <a class="link" href="glib-Message-Logging.html#g-warning" title="g_warning()"><code class="function">g_warning()</code></a>,
  101. <a class="link" href="glib-Warnings-and-Assertions.html#g-return-if-fail" title="g_return_if_fail()"><code class="function">g_return_if_fail()</code></a>, <a class="link" href="glib-Testing.html#g-assert" title="g_assert()"><code class="function">g_assert()</code></a>, <a class="link" href="glib-Message-Logging.html#g-error" title="g_error()"><code class="function">g_error()</code></a>, or some similar facility.
  102. (Incidentally, remember that the <a class="link" href="glib-Message-Logging.html#g-error" title="g_error()"><code class="function">g_error()</code></a> function should
  103. <span class="emphasis"><em>only</em></span> be used for programming errors, it should not be used
  104. to print any error reportable via <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>.)
  105. </p>
  106. <p>
  107. Examples of recoverable runtime errors are "file not found" or "failed to parse
  108. input." Examples of programming errors are "NULL passed to <code class="function">strcmp()</code>" or
  109. "attempted to free the same pointer twice." These two kinds of errors are
  110. fundamentally different: runtime errors should be handled or reported to the
  111. user, programming errors should be eliminated by fixing the bug in the program.
  112. This is why most functions in GLib and GTK+ do not use the <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> facility.
  113. </p>
  114. <p>
  115. Functions that can fail take a return location for a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> as their last argument.
  116. For example:
  117. </p>
  118. <div class="informalexample"><pre class="programlisting">
  119. gboolean g_file_get_contents (const gchar *filename,
  120. gchar **contents,
  121. gsize *length,
  122. GError **error);
  123. </pre></div>
  124. <p>
  125. If you pass a non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> value for the <code class="literal">error</code> argument, it should
  126. point to a location where an error can be placed. For example:
  127. </p>
  128. <div class="informalexample"><pre class="programlisting">
  129. gchar *contents;
  130. GError *err = NULL;
  131. g_file_get_contents ("foo.txt", &amp;contents, NULL, &amp;err);
  132. g_assert ((contents == NULL &amp;&amp; err != NULL) || (contents != NULL &amp;&amp; err == NULL));
  133. if (err != NULL)
  134. {
  135. /* Report error to user, and free error */
  136. g_assert (contents == NULL);
  137. fprintf (stderr, "Unable to read file: %s\n", err-&gt;message);
  138. g_error_free (err);
  139. }
  140. else
  141. {
  142. /* Use file contents */
  143. g_assert (contents != NULL);
  144. }
  145. </pre></div>
  146. <p>
  147. Note that <code class="literal">err != NULL</code> in this example is a
  148. <span class="emphasis"><em>reliable</em></span> indicator of whether
  149. <a class="link" href="glib-File-Utilities.html#g-file-get-contents" title="g_file_get_contents ()"><code class="function">g_file_get_contents()</code></a> failed. Additionally, <a class="link" href="glib-File-Utilities.html#g-file-get-contents" title="g_file_get_contents ()"><code class="function">g_file_get_contents()</code></a> returns
  150. a boolean which indicates whether it was successful.
  151. </p>
  152. <p>
  153. Because <a class="link" href="glib-File-Utilities.html#g-file-get-contents" title="g_file_get_contents ()"><code class="function">g_file_get_contents()</code></a> returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> on failure, if you are only
  154. interested in whether it failed and don't need to display an error message, you
  155. can pass <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> for the <code class="literal">error</code> argument:
  156. </p>
  157. <div class="informalexample"><pre class="programlisting">
  158. if (g_file_get_contents ("foo.txt", &amp;contents, NULL, NULL)) /* ignore errors */
  159. /* no error occurred */ ;
  160. else
  161. /* error */ ;
  162. </pre></div>
  163. <p>
  164. </p>
  165. <p>
  166. The <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> object contains three fields: <code class="literal">domain</code> indicates
  167. the module the error-reporting function is located in, <code class="literal">code</code>
  168. indicates the specific error that occurred, and <code class="literal">message</code> is a
  169. user-readable error message with as many details as possible. Several functions
  170. are provided to deal with an error received from a called function:
  171. <a class="link" href="glib-Error-Reporting.html#g-error-matches" title="g_error_matches ()"><code class="function">g_error_matches()</code></a> returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the error matches a given domain and code,
  172. <a class="link" href="glib-Error-Reporting.html#g-propagate-error" title="g_propagate_error ()"><code class="function">g_propagate_error()</code></a> copies an error into an error location (so the calling
  173. function will receive it), and <a class="link" href="glib-Error-Reporting.html#g-clear-error" title="g_clear_error ()"><code class="function">g_clear_error()</code></a> clears an error location by
  174. freeing the error and resetting the location to <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. To display an error to the
  175. user, simply display <code class="literal">error-&gt;message</code>, perhaps along with
  176. additional context known only to the calling function (the file being opened, or
  177. whatever -- though in the <a class="link" href="glib-File-Utilities.html#g-file-get-contents" title="g_file_get_contents ()"><code class="function">g_file_get_contents()</code></a> case,
  178. <code class="literal">error-&gt;message</code> already contains a filename).
  179. </p>
  180. <p>
  181. When implementing a function that can report errors, the basic tool is
  182. <a class="link" href="glib-Error-Reporting.html#g-set-error" title="g_set_error ()"><code class="function">g_set_error()</code></a>. Typically, if a fatal error occurs you want to <a class="link" href="glib-Error-Reporting.html#g-set-error" title="g_set_error ()"><code class="function">g_set_error()</code></a>,
  183. then return immediately. <a class="link" href="glib-Error-Reporting.html#g-set-error" title="g_set_error ()"><code class="function">g_set_error()</code></a> does nothing if the error location passed
  184. to it is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. Here's an example:
  185. </p>
  186. <div class="informalexample"><pre class="programlisting">
  187. gint
  188. foo_open_file (GError **error)
  189. {
  190. gint fd;
  191. fd = open ("file.txt", O_RDONLY);
  192. if (fd &lt; 0)
  193. {
  194. g_set_error (error,
  195. FOO_ERROR, /* error domain */
  196. FOO_ERROR_BLAH, /* error code */
  197. "Failed to open file: %s", /* error message format string */
  198. g_strerror (errno));
  199. return -1;
  200. }
  201. else
  202. return fd;
  203. }
  204. </pre></div>
  205. <p>
  206. </p>
  207. <p>
  208. Things are somewhat more complicated if you yourself call another function that
  209. can report a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>. If the sub-function indicates fatal errors in some way
  210. other than reporting a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>, such as by returning <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> on success, you can
  211. simply do the following:
  212. </p>
  213. <div class="informalexample"><pre class="programlisting">
  214. gboolean
  215. my_function_that_can_fail (GError **err)
  216. {
  217. g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
  218. if (!sub_function_that_can_fail (err))
  219. {
  220. /* assert that error was set by the sub-function */
  221. g_assert (err == NULL || *err != NULL);
  222. return FALSE;
  223. }
  224. /* otherwise continue, no error occurred */
  225. g_assert (err == NULL || *err == NULL);
  226. }
  227. </pre></div>
  228. <p>
  229. </p>
  230. <p>
  231. If the sub-function does not indicate errors other than by reporting a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>,
  232. you need to create a temporary <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> since the passed-in one may be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
  233. <a class="link" href="glib-Error-Reporting.html#g-propagate-error" title="g_propagate_error ()"><code class="function">g_propagate_error()</code></a> is intended for use in this case.
  234. </p>
  235. <div class="informalexample"><pre class="programlisting">
  236. gboolean
  237. my_function_that_can_fail (GError **err)
  238. {
  239. GError *tmp_error;
  240. g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
  241. tmp_error = NULL;
  242. sub_function_that_can_fail (&amp;tmp_error);
  243. if (tmp_error != NULL)
  244. {
  245. /* store tmp_error in err, if err != NULL,
  246. * otherwise call g_error_free() on tmp_error
  247. */
  248. g_propagate_error (err, tmp_error);
  249. return FALSE;
  250. }
  251. /* otherwise continue, no error occurred */
  252. }
  253. </pre></div>
  254. <p>
  255. </p>
  256. <p>
  257. Error pileups are always a bug. For example, this code is incorrect:
  258. </p>
  259. <div class="informalexample"><pre class="programlisting">
  260. gboolean
  261. my_function_that_can_fail (GError **err)
  262. {
  263. GError *tmp_error;
  264. g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
  265. tmp_error = NULL;
  266. sub_function_that_can_fail (&amp;tmp_error);
  267. other_function_that_can_fail (&amp;tmp_error);
  268. if (tmp_error != NULL)
  269. {
  270. g_propagate_error (err, tmp_error);
  271. return FALSE;
  272. }
  273. }
  274. </pre></div>
  275. <p>
  276. <code class="literal">tmp_error</code> should be checked immediately after
  277. <code class="function"><code class="function">sub_function_that_can_fail()</code></code>, and either cleared or propagated upward. The rule
  278. is: <span class="emphasis"><em>after each error, you must either handle the error, or return it to the
  279. calling function</em></span>. Note that passing <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> for the error location is the
  280. equivalent of handling an error by always doing nothing about it. So the
  281. following code is fine, assuming errors in <code class="function"><code class="function">sub_function_that_can_fail()</code></code> are not
  282. fatal to <code class="function"><code class="function">my_function_that_can_fail()</code></code>:
  283. </p>
  284. <div class="informalexample"><pre class="programlisting">
  285. gboolean
  286. my_function_that_can_fail (GError **err)
  287. {
  288. GError *tmp_error;
  289. g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
  290. sub_function_that_can_fail (NULL); /* ignore errors */
  291. tmp_error = NULL;
  292. other_function_that_can_fail (&amp;tmp_error);
  293. if (tmp_error != NULL)
  294. {
  295. g_propagate_error (err, tmp_error);
  296. return FALSE;
  297. }
  298. }
  299. </pre></div>
  300. <p>
  301. </p>
  302. <p>
  303. Note that passing <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> for the error location <span class="emphasis"><em>ignores</em></span>
  304. errors; it's equivalent to <code class="literal">try { <code class="function">sub_function_that_can_fail()</code>; } catch
  305. (...) {}</code> in C++. It does <span class="emphasis"><em>not</em></span> mean to leave errors
  306. unhandled; it means to handle them by doing nothing.
  307. </p>
  308. <p>
  309. Error domains and codes are conventionally named as follows:
  310. </p>
  311. <div class="itemizedlist"><ul type="disc">
  312. <li>
  313. <p>
  314. The error domain is called
  315. <code class="literal">&lt;NAMESPACE&gt;_&lt;MODULE&gt;_ERROR</code>, for example
  316. <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-ERROR:CAPS" title="G_SPAWN_ERROR"><code class="literal">G_SPAWN_ERROR</code></a> or <a class="link" href="glib-Threads.html#G-THREAD-ERROR:CAPS" title="G_THREAD_ERROR"><code class="literal">G_THREAD_ERROR</code></a>:
  317. </p>
  318. <div class="informalexample"><pre class="programlisting">
  319. #define G_SPAWN_ERROR g_spawn_error_quark ()
  320. GQuark
  321. g_spawn_error_quark (void)
  322. {
  323. return g_quark_from_static_string ("g-spawn-error-quark");
  324. }
  325. </pre></div>
  326. <p>
  327. </p>
  328. </li>
  329. <li><p>
  330. The error codes are in an enumeration called
  331. <code class="literal">&lt;Namespace&gt;&lt;Module&gt;Error</code>; for example,
  332. <a class="link" href="glib-Threads.html#GThreadError" title="enum GThreadError"><span class="type">GThreadError</span></a> or <a class="link" href="glib-Spawning-Processes.html#GSpawnError" title="enum GSpawnError"><span class="type">GSpawnError</span></a>.
  333. </p></li>
  334. <li><p>
  335. Members of the error code enumeration are called <code class="literal">&lt;NAMESPACE&gt;_&lt;MODULE&gt;_ERROR_&lt;CODE&gt;</code>, for example <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-ERROR-FORK:CAPS"><code class="literal">G_SPAWN_ERROR_FORK</code></a> or <a class="link" href="glib-Threads.html#G-THREAD-ERROR-AGAIN:CAPS"><code class="literal">G_THREAD_ERROR_AGAIN</code></a>.
  336. </p></li>
  337. <li><p>
  338. If there's a "generic" or "unknown" error code for unrecoverable errors it
  339. doesn't make sense to distinguish with specific codes, it should be called
  340. <code class="literal">&lt;NAMESPACE&gt;_&lt;MODULE&gt;_ERROR_FAILED</code>, for
  341. example <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-ERROR-FAILED:CAPS"><code class="literal">G_SPAWN_ERROR_FAILED</code></a> or <code class="literal">G_THREAD_ERROR_FAILED</code>.
  342. </p></li>
  343. </ul></div>
  344. <p>
  345. </p>
  346. <p>
  347. Summary of rules for use of <span class="type">""</span>
  348. </p>
  349. <div class="itemizedlist"><ul type="disc">
  350. <li><p>
  351. Do not report programming errors via <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>.
  352. </p></li>
  353. <li><p>
  354. The last argument of a function that returns an error should be a
  355. location where a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> can be placed (i.e. "<a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>** error"). If
  356. <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> is used with varargs, the <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>** should be the last
  357. argument before the "...".
  358. </p></li>
  359. <li><p>
  360. The caller may pass <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> for the <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>** if they are not interested
  361. in details of the exact error that occurred.
  362. </p></li>
  363. <li><p>
  364. If <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> is passed for the <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>** argument, then errors should
  365. not be returned to the caller, but your function should still
  366. abort and return if an error occurs. That is, control flow should
  367. not be affected by whether the caller wants to get a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>.
  368. </p></li>
  369. <li><p>
  370. If a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> is reported, then your function by definition
  371. <span class="emphasis"><em>had a fatal failure and did not complete whatever it was supposed
  372. to do</em></span>. If the failure was not fatal, then you handled it
  373. and you should not report it. If it was fatal, then you must report it
  374. and discontinue whatever you were doing immediately.
  375. </p></li>
  376. <li><p>
  377. A <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>* must be initialized to <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> before passing its address to
  378. a function that can report errors.
  379. </p></li>
  380. <li><p>
  381. "Piling up" errors is always a bug. That is, if you assign a new
  382. <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> to a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>* that is non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, thus overwriting the previous
  383. error, it indicates that you should have aborted the operation instead
  384. of continuing. If you were able to continue, you should have cleared
  385. the previous error with <a class="link" href="glib-Error-Reporting.html#g-clear-error" title="g_clear_error ()"><code class="function">g_clear_error()</code></a>. <a class="link" href="glib-Error-Reporting.html#g-set-error" title="g_set_error ()"><code class="function">g_set_error()</code></a> will complain
  386. if you pile up errors.
  387. </p></li>
  388. <li><p>
  389. By convention, if you return a boolean value indicating success
  390. then <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> means success and <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> means failure. If <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> is returned,
  391. the error <span class="emphasis"><em>must</em></span> be set to a non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> value.
  392. </p></li>
  393. <li><p>
  394. A <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> return value is also frequently used to mean that an error
  395. occurred. You should make clear in your documentation whether <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> is
  396. a valid return value in non-error cases; if <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> is a valid value,
  397. then users must check whether an error was returned to see if the
  398. function succeeded.
  399. </p></li>
  400. <li><p>
  401. When implementing a function that can report errors, you may want to
  402. add a check at the top of your function that the error return location
  403. is either <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> or contains a <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> error
  404. (e.g. <code class="literal">g_return_if_fail (error == NULL || *error ==
  405. NULL);</code>).
  406. </p></li>
  407. </ul></div>
  408. <p>
  409. </p>
  410. </div>
  411. <div class="refsect1" lang="en">
  412. <a name="glib-Error-Reporting.details"></a><h2>Details</h2>
  413. <div class="refsect2" lang="en">
  414. <a name="GError"></a><h3>GError</h3>
  415. <pre class="programlisting">typedef struct {
  416. GQuark domain;
  417. gint code;
  418. gchar *message;
  419. } GError;
  420. </pre>
  421. <p>
  422. The <span class="structname">GError</span> structure contains
  423. information about an error that has occurred.
  424. </p>
  425. <div class="variablelist"><table border="0">
  426. <col align="left" valign="top">
  427. <tbody>
  428. <tr>
  429. <td><p><span class="term"><a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> <em class="structfield"><code>domain</code></em>;</span></p></td>
  430. <td>error domain, e.g. <a class="link" href="glib-File-Utilities.html#G-FILE-ERROR:CAPS" title="G_FILE_ERROR"><span class="type">G_FILE_ERROR</span></a>.
  431. </td>
  432. </tr>
  433. <tr>
  434. <td><p><span class="term"><a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> <em class="structfield"><code>code</code></em>;</span></p></td>
  435. <td>error code, e.g. <a class="link" href="glib-File-Utilities.html#G-FILE-ERROR-NOENT:CAPS"><code class="literal">G_FILE_ERROR_NOENT</code></a>.
  436. </td>
  437. </tr>
  438. <tr>
  439. <td><p><span class="term"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *<em class="structfield"><code>message</code></em>;</span></p></td>
  440. <td>human-readable informative error message.
  441. </td>
  442. </tr>
  443. </tbody>
  444. </table></div>
  445. </div>
  446. <hr>
  447. <div class="refsect2" lang="en">
  448. <a name="g-error-new"></a><h3>g_error_new ()</h3>
  449. <pre class="programlisting"><a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a>* g_error_new (<a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> domain,
  450. <a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> code,
  451. const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *format,
  452. ...);</pre>
  453. <p>
  454. Creates a new <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> with the given <em class="parameter"><code>domain</code></em> and <em class="parameter"><code>code</code></em>,
  455. and a message formatted with <em class="parameter"><code>format</code></em>.</p>
  456. <p>
  457. </p>
  458. <div class="variablelist"><table border="0">
  459. <col align="left" valign="top">
  460. <tbody>
  461. <tr>
  462. <td><p><span class="term"><em class="parameter"><code>domain</code></em> :</span></p></td>
  463. <td> error domain
  464. </td>
  465. </tr>
  466. <tr>
  467. <td><p><span class="term"><em class="parameter"><code>code</code></em> :</span></p></td>
  468. <td> error code
  469. </td>
  470. </tr>
  471. <tr>
  472. <td><p><span class="term"><em class="parameter"><code>format</code></em> :</span></p></td>
  473. <td> <code class="function">printf()</code>-style format for error message
  474. </td>
  475. </tr>
  476. <tr>
  477. <td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
  478. <td> parameters for message format
  479. </td>
  480. </tr>
  481. <tr>
  482. <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
  483. <td> a new <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>
  484. </td>
  485. </tr>
  486. </tbody>
  487. </table></div>
  488. </div>
  489. <hr>
  490. <div class="refsect2" lang="en">
  491. <a name="g-error-new-literal"></a><h3>g_error_new_literal ()</h3>
  492. <pre class="programlisting"><a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a>* g_error_new_literal (<a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> domain,
  493. <a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> code,
  494. const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *message);</pre>
  495. <p>
  496. Creates a new <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>; unlike <a class="link" href="glib-Error-Reporting.html#g-error-new" title="g_error_new ()"><code class="function">g_error_new()</code></a>, <em class="parameter"><code>message</code></em> is not
  497. a <code class="function">printf()</code>-style format string. Use this
  498. function if <em class="parameter"><code>message</code></em> contains text you don't have control over,
  499. that could include <code class="function">printf()</code> escape sequences.</p>
  500. <p>
  501. </p>
  502. <div class="variablelist"><table border="0">
  503. <col align="left" valign="top">
  504. <tbody>
  505. <tr>
  506. <td><p><span class="term"><em class="parameter"><code>domain</code></em> :</span></p></td>
  507. <td> error domain
  508. </td>
  509. </tr>
  510. <tr>
  511. <td><p><span class="term"><em class="parameter"><code>code</code></em> :</span></p></td>
  512. <td> error code
  513. </td>
  514. </tr>
  515. <tr>
  516. <td><p><span class="term"><em class="parameter"><code>message</code></em> :</span></p></td>
  517. <td> error message
  518. </td>
  519. </tr>
  520. <tr>
  521. <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
  522. <td> a new <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>
  523. </td>
  524. </tr>
  525. </tbody>
  526. </table></div>
  527. </div>
  528. <hr>
  529. <div class="refsect2" lang="en">
  530. <a name="g-error-free"></a><h3>g_error_free ()</h3>
  531. <pre class="programlisting">void g_error_free (<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> *error);</pre>
  532. <p>
  533. Frees a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> and associated resources.</p>
  534. <p>
  535. </p>
  536. <div class="variablelist"><table border="0">
  537. <col align="left" valign="top">
  538. <tbody><tr>
  539. <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
  540. <td> a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>
  541. </td>
  542. </tr></tbody>
  543. </table></div>
  544. </div>
  545. <hr>
  546. <div class="refsect2" lang="en">
  547. <a name="g-error-copy"></a><h3>g_error_copy ()</h3>
  548. <pre class="programlisting"><a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a>* g_error_copy (const <a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> *error);</pre>
  549. <p>
  550. Makes a copy of <em class="parameter"><code>error</code></em>.</p>
  551. <p>
  552. </p>
  553. <div class="variablelist"><table border="0">
  554. <col align="left" valign="top">
  555. <tbody>
  556. <tr>
  557. <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
  558. <td> a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>
  559. </td>
  560. </tr>
  561. <tr>
  562. <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
  563. <td> a new <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>
  564. </td>
  565. </tr>
  566. </tbody>
  567. </table></div>
  568. </div>
  569. <hr>
  570. <div class="refsect2" lang="en">
  571. <a name="g-error-matches"></a><h3>g_error_matches ()</h3>
  572. <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> g_error_matches (const <a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> *error,
  573. <a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> domain,
  574. <a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> code);</pre>
  575. <p>
  576. Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <em class="parameter"><code>error</code></em> matches <em class="parameter"><code>domain</code></em> and <em class="parameter"><code>code</code></em>, <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>
  577. otherwise.</p>
  578. <p>
  579. </p>
  580. <div class="variablelist"><table border="0">
  581. <col align="left" valign="top">
  582. <tbody>
  583. <tr>
  584. <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
  585. <td> a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>
  586. </td>
  587. </tr>
  588. <tr>
  589. <td><p><span class="term"><em class="parameter"><code>domain</code></em> :</span></p></td>
  590. <td> an error domain
  591. </td>
  592. </tr>
  593. <tr>
  594. <td><p><span class="term"><em class="parameter"><code>code</code></em> :</span></p></td>
  595. <td> an error code
  596. </td>
  597. </tr>
  598. <tr>
  599. <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
  600. <td> whether <em class="parameter"><code>error</code></em> has <em class="parameter"><code>domain</code></em> and <em class="parameter"><code>code</code></em>
  601. </td>
  602. </tr>
  603. </tbody>
  604. </table></div>
  605. </div>
  606. <hr>
  607. <div class="refsect2" lang="en">
  608. <a name="g-set-error"></a><h3>g_set_error ()</h3>
  609. <pre class="programlisting">void g_set_error (<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **err,
  610. <a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> domain,
  611. <a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> code,
  612. const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *format,
  613. ...);</pre>
  614. <p>
  615. Does nothing if <em class="parameter"><code>err</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>; if <em class="parameter"><code>err</code></em> is non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, then *<em class="parameter"><code>err</code></em> must
  616. be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. A new <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> is created and assigned to *<em class="parameter"><code>err</code></em>.</p>
  617. <p>
  618. </p>
  619. <div class="variablelist"><table border="0">
  620. <col align="left" valign="top">
  621. <tbody>
  622. <tr>
  623. <td><p><span class="term"><em class="parameter"><code>err</code></em> :</span></p></td>
  624. <td> a return location for a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>
  625. </td>
  626. </tr>
  627. <tr>
  628. <td><p><span class="term"><em class="parameter"><code>domain</code></em> :</span></p></td>
  629. <td> error domain
  630. </td>
  631. </tr>
  632. <tr>
  633. <td><p><span class="term"><em class="parameter"><code>code</code></em> :</span></p></td>
  634. <td> error code
  635. </td>
  636. </tr>
  637. <tr>
  638. <td><p><span class="term"><em class="parameter"><code>format</code></em> :</span></p></td>
  639. <td> <code class="function">printf()</code>-style format
  640. </td>
  641. </tr>
  642. <tr>
  643. <td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
  644. <td> args for <em class="parameter"><code>format</code></em>
  645. </td>
  646. </tr>
  647. </tbody>
  648. </table></div>
  649. </div>
  650. <hr>
  651. <div class="refsect2" lang="en">
  652. <a name="g-propagate-error"></a><h3>g_propagate_error ()</h3>
  653. <pre class="programlisting">void g_propagate_error (<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **dest,
  654. <a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> *src);</pre>
  655. <p>
  656. If <em class="parameter"><code>dest</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, free <em class="parameter"><code>src</code></em>; otherwise, moves <em class="parameter"><code>src</code></em> into *<em class="parameter"><code>dest</code></em>.
  657. The error variable <em class="parameter"><code>dest</code></em> points to must be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.</p>
  658. <p>
  659. </p>
  660. <div class="variablelist"><table border="0">
  661. <col align="left" valign="top">
  662. <tbody>
  663. <tr>
  664. <td><p><span class="term"><em class="parameter"><code>dest</code></em> :</span></p></td>
  665. <td> error return location
  666. </td>
  667. </tr>
  668. <tr>
  669. <td><p><span class="term"><em class="parameter"><code>src</code></em> :</span></p></td>
  670. <td> error to move into the return location
  671. </td>
  672. </tr>
  673. </tbody>
  674. </table></div>
  675. </div>
  676. <hr>
  677. <div class="refsect2" lang="en">
  678. <a name="g-clear-error"></a><h3>g_clear_error ()</h3>
  679. <pre class="programlisting">void g_clear_error (<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **err);</pre>
  680. <p>
  681. If <em class="parameter"><code>err</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, does nothing. If <em class="parameter"><code>err</code></em> is non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>,
  682. calls <a class="link" href="glib-Error-Reporting.html#g-error-free" title="g_error_free ()"><code class="function">g_error_free()</code></a> on *<em class="parameter"><code>err</code></em> and sets *<em class="parameter"><code>err</code></em> to <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.</p>
  683. <p>
  684. </p>
  685. <div class="variablelist"><table border="0">
  686. <col align="left" valign="top">
  687. <tbody><tr>
  688. <td><p><span class="term"><em class="parameter"><code>err</code></em> :</span></p></td>
  689. <td> a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> return location
  690. </td>
  691. </tr></tbody>
  692. </table></div>
  693. </div>
  694. <hr>
  695. <div class="refsect2" lang="en">
  696. <a name="g-prefix-error"></a><h3>g_prefix_error ()</h3>
  697. <pre class="programlisting">void g_prefix_error (<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **err,
  698. const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *format,
  699. ...);</pre>
  700. <p>
  701. Formats a string according to <em class="parameter"><code>format</code></em> and
  702. prefix it to an existing error message. If
  703. <em class="parameter"><code>err</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> (ie: no error variable) then do
  704. nothing.
  705. </p>
  706. <p>
  707. If *<em class="parameter"><code>err</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> (ie: an error variable is
  708. present but there is no error condition) then
  709. also do nothing. Whether or not it makes
  710. sense to take advantage of this feature is up
  711. to you.</p>
  712. <p>
  713. </p>
  714. <div class="variablelist"><table border="0">
  715. <col align="left" valign="top">
  716. <tbody>
  717. <tr>
  718. <td><p><span class="term"><em class="parameter"><code>err</code></em> :</span></p></td>
  719. <td> a return location for a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>
  720. </td>
  721. </tr>
  722. <tr>
  723. <td><p><span class="term"><em class="parameter"><code>format</code></em> :</span></p></td>
  724. <td> <code class="function">printf()</code>-style format string
  725. </td>
  726. </tr>
  727. <tr>
  728. <td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
  729. <td> arguments to <em class="parameter"><code>format</code></em>
  730. </td>
  731. </tr>
  732. </tbody>
  733. </table></div>
  734. <p class="since">Since 2.16
  735. </p>
  736. </div>
  737. <hr>
  738. <div class="refsect2" lang="en">
  739. <a name="g-propagate-prefixed-error"></a><h3>g_propagate_prefixed_error ()</h3>
  740. <pre class="programlisting">void g_propagate_prefixed_error (<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **dest,
  741. <a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> *src,
  742. const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *format,
  743. ...);</pre>
  744. <p>
  745. If <em class="parameter"><code>dest</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, free <em class="parameter"><code>src</code></em>; otherwise,
  746. moves <em class="parameter"><code>src</code></em> into *<em class="parameter"><code>dest</code></em>. *<em class="parameter"><code>dest</code></em> must be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
  747. After the move, add a prefix as with
  748. <a class="link" href="glib-Error-Reporting.html#g-prefix-error" title="g_prefix_error ()"><code class="function">g_prefix_error()</code></a>.</p>
  749. <p>
  750. </p>
  751. <div class="variablelist"><table border="0">
  752. <col align="left" valign="top">
  753. <tbody>
  754. <tr>
  755. <td><p><span class="term"><em class="parameter"><code>dest</code></em> :</span></p></td>
  756. <td> error return location
  757. </td>
  758. </tr>
  759. <tr>
  760. <td><p><span class="term"><em class="parameter"><code>src</code></em> :</span></p></td>
  761. <td> error to move into the return location
  762. </td>
  763. </tr>
  764. <tr>
  765. <td><p><span class="term"><em class="parameter"><code>format</code></em> :</span></p></td>
  766. <td> <code class="function">printf()</code>-style format string
  767. </td>
  768. </tr>
  769. <tr>
  770. <td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
  771. <td> arguments to <em class="parameter"><code>format</code></em>
  772. </td>
  773. </tr>
  774. </tbody>
  775. </table></div>
  776. <p class="since">Since 2.16
  777. </p>
  778. </div>
  779. </div>
  780. </div>
  781. <div class="footer">
  782. <hr>
  783. Generated by GTK-Doc V1.10</div>
  784. </body>
  785. </html>