IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 4, 2006, 12:36:22 PM (20 years ago)
Author:
jhoblitt
Message:

improved database error handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/regtool.c

    r9189 r9232  
    7171    char *query =
    7272        "SELECT newExp.*"
    73         "   FROM newExp"
     73        " FROM newExp"
    7474        " LEFT JOIN newImfile USING(exp_tag)"
    7575        " LEFT JOIN rawScienceExp USING(exp_tag)"
     
    9191    psArray *output = p_psDBFetchResult(config->dbh);
    9292    if (!output) {
     93        psError(PS_ERR_UNKNOWN, false, "database error");
     94        return false;
     95    }
     96    if (!psArrayLength(output)) {
    9397        // XXX check psError here
    94         psError(PS_ERR_UNKNOWN, false, "failed to fetch the database result");
    95         return false;
     98        psError(PS_ERR_UNKNOWN, false, "no pending newExp rows found");
     99        psFree(output);
     100        return true;
    96101    }
    97102
     
    144149    psArray *output = p_psDBFetchResult(config->dbh);
    145150    if (!output) {
     151        psError(PS_ERR_UNKNOWN, false, "database error");
     152        return false;
     153    }
     154    if (!psArrayLength(output)) {
    146155        // XXX check psError here
    147         psError(PS_ERR_UNKNOWN, false, "failed to fetch the database result");
    148         return false;
     156        psError(PS_ERR_UNKNOWN, false, "no pending newImfile rows found");
     157        psFree(output);
     158        return true;
    149159    }
    150160
     
    183193    psString query = psStringCopy(
    184194        "SELECT newExp.*"
    185         "   FROM newExp"
     195        " FROM newExp"
    186196        " LEFT JOIN newImfile USING(exp_tag)"
    187197        " LEFT JOIN rawScienceExp USING(exp_tag)"
     
    218228    psArray *output = p_psDBFetchResult(config->dbh);
    219229    if (!output) {
     230        psError(PS_ERR_UNKNOWN, false, "database error");
     231        return false;
     232    }
     233    if (!psArrayLength(output)) {
    220234        // XXX check psError here
    221         psError(PS_ERR_UNKNOWN, false, "failed to fetch the database result");
     235        psError(PS_ERR_UNKNOWN, false, "no pending newExp rows found");
     236        psFree(output);
    222237        return false;
    223238    }
     
    510525    psFree(query);
    511526
    512     psArray *newImfiles = p_psDBFetchResult(config->dbh);
    513     if (!newImfiles) {
     527    psArray *output = p_psDBFetchResult(config->dbh);
     528    if (!output) {
     529        psError(PS_ERR_UNKNOWN, false, "database error");
     530        return false;
     531    }
     532    if (!psArrayLength(output)) {
    514533        // XXX check psError here
    515         psError(PS_ERR_UNKNOWN, false, "failed to fetch the database result");
     534        psError(PS_ERR_UNKNOWN, false, "no pending newImfile rows found");
     535        psFree(output);
    516536        return false;
    517537    }
Note: See TracChangeset for help on using the changeset viewer.