<html>
<head>
<base href="https://bugs.freedesktop.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - The tutorial should have a section on error handling"
href="https://bugs.freedesktop.org/show_bug.cgi?id=78140#c3">Comment # 3</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW --- - The tutorial should have a section on error handling"
href="https://bugs.freedesktop.org/show_bug.cgi?id=78140">bug 78140</a>
from <span class="vcard"><a class="email" href="mailto:psychon@znc.in" title="Uli Schlachter <psychon@znc.in>"> <span class="fn">Uli Schlachter</span></a>
</span></b>
<pre>(In reply to <a href="show_bug.cgi?id=78140#c2">comment #2</a>)
<span class="quote">> I should be able to put together at least a prototype myself but I need to
> ask a few more questions.</span >
Thanks a lot!
<span class="quote">> Do I need to call xcb_connection_has_error after absolutely every function
> that gets passed a connection?</span >
Nope. Nothing bad happens when you use an xcb_connection_t that is an error
state. Must functions will just return e.g. NULL (however, no one ever expects
e.g. xcb_get_setup() to return NULL, so other code can still crash...).
<span class="quote">> Is there a function to get an error string for each error (keep in mind that
> one may want to sometimes localize error messages so this is not as easy as
> it seems).</span >
Nope, and I wouldn't want to add one exactly because of things like
localization. I guess you are expected to write your own function that
translates the ~5 error codes that are currently in-use into a string and that
returns something like "unknown error 42" for other values.
E.g. qt does the following:
<a href="https://qt.gitorious.org/qt/qtbase/source/d52b00e1d3cc60c81b54a89d6da488dc4bbce384:src/plugins/platforms/xcb/qxcbconnection.cpp#L95-126">https://qt.gitorious.org/qt/qtbase/source/d52b00e1d3cc60c81b54a89d6da488dc4bbce384:src/plugins/platforms/xcb/qxcbconnection.cpp#L95-126</a>
<span class="quote">> How do I check for errors with the xcb_disconnect function (I know that
> free(3) does not give errors but what about close(2))?</span >
There just are no errors. :-)
Also, there aren't many sensible things that can be done if close(),
pthread_mutex_destroy() or pthread_cond_destroy() fail (AFAIR on some systems
close() can fail and still have closed the FD already, so retrying would be
unsafe in multi-threaded programs anyway).
So if any errors occur during xcb_disconnect(), you'll get a memory / file
descriptor leak.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug.</li>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>