Changeset c73a22d


Ignore:
Timestamp:
Mar 6, 2011, 2:14:39 PM (13 years ago)
Author:
Karl Ramm <kcr@1ts.org>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
00842c3
Parents:
488913a
git-author:
Karl Ramm <kcr@1ts.org> (02/11/11 23:57:39)
git-committer:
Karl Ramm <kcr@1ts.org> (03/06/11 14:14:39)
Message:
when something goes wrong, give more information about what happened

These various utility functions, instead of just saying "there was an
error", should report to the user what the library thinks went wrong
so they user has some small chance of debugging the problem.

Reviewed-By: Nelson Elhage <nelhage@nelhage.com>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zephyr.c

    r488913a rc73a22d  
    211211{
    212212  int ret = 0;
     213  Code_t code;
     214
    213215  if (owl_global_is_havezephyr(&g)) {
    214216    int i;
    215217    /* sub without defaults */
    216     if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) {
    217       owl_function_error("Error subscribing to zephyr notifications.");
     218    code = ZSubscribeToSansDefaults(subs, count, 0);
     219    if (code != ZERR_NONE) {
     220      owl_function_error("Error subscribing to zephyr notifications: %s",
     221                         error_message(code));
    218222      ret=-2;
    219223    }
     
    351355{
    352356#ifdef HAVE_LIBZEPHYR
     357  Code_t ret;
     358
    353359  if (owl_global_is_havezephyr(&g)) {
    354360    ZSubscription_t subs[10];
    355    
    356     if (ZSubscribeTo(subs,0,0) != ZERR_NONE) {
    357       owl_function_error("Error subscribing to default zephyr notifications.");
     361
     362    ret = ZSubscribeTo(subs, 0, 0);
     363    if (ret != ZERR_NONE) {
     364      owl_function_error("Error subscribing to default zephyr notifications: %s.",
     365                           error_message(ret));
    358366      return(-1);
    359367    }
     
    435443#ifdef HAVE_LIBZEPHYR
    436444  ZSubscription_t subs[5];
     445  Code_t ret;
    437446
    438447  subs[0].zsub_class=zstr(class);
     
    441450
    442451  ZResetAuthentication();
    443   if (ZSubscribeTo(subs,1,0) != ZERR_NONE) {
    444     owl_function_error("Error subbing to <%s,%s,%s>", class, inst, recip);
     452  ret = ZSubscribeTo(subs, 1, 0);
     453  if (ret != ZERR_NONE) {
     454    owl_function_error("Error subbing to <%s,%s,%s>: %s",
     455                       class, inst, recip,
     456                       error_message(ret));
    445457    return(-2);
    446458  }
     
    456468#ifdef HAVE_LIBZEPHYR
    457469  ZSubscription_t subs[5];
     470  Code_t ret;
    458471
    459472  subs[0].zsub_class=zstr(class);
     
    462475
    463476  ZResetAuthentication();
    464   if (ZUnsubscribeTo(subs,1,0) != ZERR_NONE) {
    465     owl_function_error("Error unsubbing from <%s,%s,%s>", class, inst, recip);
     477  ret = ZUnsubscribeTo(subs, 1, 0);
     478  if (ret != ZERR_NONE) {
     479    owl_function_error("Error unsubbing from <%s,%s,%s>: %s",
     480                       class, inst, recip,
     481                       error_message(ret));
    466482    return(-2);
    467483  }
     
    668684{
    669685#ifdef HAVE_LIBZEPHYR
    670   int ret;
     686  Code_t ret;
    671687  ZNotice_t notice;
    672688   
     
    703719  g_free(notice.z_message);
    704720  ZFreeNotice(&notice);
    705   if (ret!=ZERR_NONE) {
    706     owl_function_error("Error sending zephyr");
     721  if (ret != ZERR_NONE) {
     722    owl_function_error("Error sending zephyr: %s", error_message(ret));
    707723    return(ret);
    708724  }
     
    11301146{
    11311147#ifdef HAVE_LIBZEPHYR
    1132   int ret, num, i, one;
     1148  Code_t ret;
     1149  int num, i, one;
    11331150  ZSubscription_t sub;
    11341151  GString *buf;
    11351152
    1136   ret=ZRetrieveSubscriptions(0, &num);
    1137   if (ret==ZERR_TOOMANYSUBS) {
    1138     return(g_strdup("Zephyr: too many subscriptions\n"));
    1139   } else if (ret || (num <= 0)) {
    1140     return(g_strdup("Zephyr: error retrieving subscriptions\n"));
    1141   }
     1153  ret = ZRetrieveSubscriptions(0, &num);
     1154  if (ret != ZERR_NONE)
     1155    return g_strdup_printf("Zephyr: Requesting subscriptions: %s\n", error_message(ret));
     1156  if (num == 0)
     1157    return g_strdup("Zephyr: No subscriptions retrieved\n");
    11421158
    11431159  buf = g_string_new("");
     
    11471163      ZFlushSubscriptions();
    11481164      g_string_free(buf, true);
    1149       return g_strdup("Error while getting subscriptions\n");
     1165      return g_strdup_printf("Zephyr: Getting subscriptions: %s\n", error_message(ret));
    11501166    } else {
    11511167      /* g_string_append_printf would be backwards. */
Note: See TracChangeset for help on using the changeset viewer.