After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 325016 - patch for better error reporting using GError
patch for better error reporting using GError
Status: RESOLVED FIXED
Product: libbtctl
Classification: Deprecated
Component: general
unspecified
Other All
: Normal enhancement
: ---
Assigned To: Edd Dumbill
Edd Dumbill
Depends on:
Blocks: 330894
 
 
Reported: 2005-12-26 18:03 UTC by Tadas Dailyda
Modified: 2006-04-19 20:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch against cvs HEAD (10.59 KB, patch)
2005-12-26 18:04 UTC, Tadas Dailyda
none Details | Review
patch against cvs HEAD (corrected) (10.52 KB, patch)
2005-12-28 19:33 UTC, Tadas Dailyda
needs-work Details | Review
patch against cvs HEAD (corrected) (11.14 KB, patch)
2006-03-31 22:55 UTC, Tadas Dailyda
needs-work Details | Review

Description Tadas Dailyda 2005-12-26 18:03:44 UTC
Please describe the problem:
This patch makes several functions use GError. Implements this idea
(http://bugzilla.gnome.org/show_bug.cgi?id=316669#c4) plus other similar
improvements.

Steps to reproduce:



Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Tadas Dailyda 2005-12-26 18:04:47 UTC
Created attachment 56399 [details] [review]
patch against cvs HEAD
Comment 2 Tadas Dailyda 2005-12-28 19:33:04 UTC
Created attachment 56475 [details] [review]
patch against cvs HEAD (corrected)
Comment 3 Bastien Nocera 2006-03-27 22:45:36 UTC
Comment on attachment 56475 [details] [review]
patch against cvs HEAD (corrected)

<snip>
> 	if (sdp_service_search_attr_req(sess, search, SDP_ATTR_REQ_RANGE, attrid, &seq)) {
>-		printf("Service Search failed\n");
>+		g_set_error (err, btctl_error_quark(),
>+			     BTCTL_ERROR_SERVICE_SEARCH_FAILED,
>+			     g_strdup_printf(_("Service search failed on device %s"), str));
>+		//printf("Service Search failed\n");

2 things (they might show up in other parts of the patch as well):
- remove those printf() if they're not needed.
- check that *err is != NULL before setting it (ie. it shouldn't crash if NULL is passed instead of a Gerror *).
Comment 4 Tadas Dailyda 2006-03-31 22:55:08 UTC
Created attachment 62491 [details] [review]
patch against cvs HEAD (corrected)

Added *err != NULL checks, removed unnecesary printf, added missing parentheses to btctl.defs
Comment 5 Bastien Nocera 2006-04-19 19:52:46 UTC
Comment on attachment 62491 [details] [review]
patch against cvs HEAD (corrected)

<snip>
>+ * Return value: 0 if successful, -1 otherwise.

This should better be a gboolean, following glib conventions.

<snip>
>+		if (*err) {
>+			g_set_error (err, btctl_error_quark(),
>+			     BTCTL_ERROR_SERVICE_SEARCH_FAILED,
>+			     g_strdup_printf(_("Service search failed on device %s"), str));

No need to use g_strdup_printf, g_set_error takes printf style arguments.

<snip>
>+    	printf("Scanning for service failed: %s\n",
>+    		err ? err->message: "");

We usually use "No reason" if there's no error message.
Comment 6 Bastien Nocera 2006-04-19 20:17:18 UTC
I made the above changes, as well as not using btctl_error_quark() directly, but add a #define for it in btctl.h

2006-04-19  Bastien Nocera  <hadess@hadess.net>

        * src/btctl.c: (btctl_controller_discover_devices),
        (btctl_controller_scan_for_service):
        * src/btctl.defs:
        * src/btctl.h:
        * src/btctlimpl.c: (btctl_controller_impl_cmd_scan), (inquiry),
        (do_search), (do_browse), (btctl_controller_impl_scan_for_service):
        * src/btctlimpl.h:
        * src/btlist.c: (main):
        Patch from Tadas Dailyda <tadas@stablebeast.com> to add more error
        reporting for btctl_controller_discover_devices and
        btctl_controller_scan_for_service (Closes: #325016)
Comment 7 Tadas Dailyda 2006-04-19 20:48:32 UTC
nice :)