IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 11, 2007, 12:14:40 PM (19 years ago)
Author:
eugene
Message:

adding pxerrors

File:
1 edited

Legend:

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

    r11033 r11037  
    5252int main(int argc, char **argv)
    5353{
     54    psExit exit_status = PS_EXIT_SUCCESS;
     55
    5456    psLibInit(NULL);
    5557
     
    7274    psLibFinalize();
    7375
    74     exit(EXIT_SUCCESS);
     76    exit(exit_status);
    7577
    7678FAIL:
     79    // use the top-most error to determine the exit status
     80    exit_status = pxerrorGetExitStatus();
     81
    7782    psFree(config);
    7883    pmConfigDone();
     
    8085    psLibFinalize();
    8186
    82     exit(EXIT_FAILURE);
     87    exit(exit_status);
    8388}
    8489
     
    9095    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
    9196    if (!status) {
    92         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit");
     97        psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
    9398        return false;
    9499    }
     
    96101    bool faulted = psMetadataLookupU64(&status, config->args, "-faulted");
    97102    if (!status) {
    98         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted");
     103        psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -faulted");
    99104        return false;
    100105    }
     
    141146
    142147    if (!p_psDBRunQuery(config->dbh, query)) {
    143         psError(PS_ERR_UNKNOWN, false, "database error");
     148        // XXX PS_EXIT_PROG_ERROR (incorrect SQL) or SYS_ERROR (database comms)
     149        psError(PXTOOLS_ERR_PROG, false, "database error");
    144150        psFree(query);
    145151        return false;
     
    149155    psArray *output = p_psDBFetchResult(config->dbh);
    150156    if (!output) {
    151         psError(PS_ERR_UNKNOWN, false, "database error");
     157        // XXX PS_EXIT_PROG_ERROR (incorrect SQL) or SYS_ERROR (database comms)
     158        psError(PXTOOLS_ERR_PROG, false, "database error");
    152159        return false;
    153160    }
    154161    if (!psArrayLength(output)) {
    155         // XXX check psError here
    156         psError(PS_ERR_UNKNOWN, false, "no pending newExp rows found");
    157162        psFree(output);
    158163        return true;
     
    160165
    161166    bool simple = false;
    162     {
    163         bool status = false;
    164         simple = psMetadataLookupBool(&status, config->args, "-simple");
    165         if (!status) {
    166             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    167             return false;
    168         }
     167    simple = psMetadataLookupBool(&status, config->args, "-simple");
     168    if (!status) {
     169        psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -simple");
     170        return false;
    169171    }
    170172
    171173    // negate simple so the default is true
    172174    if (!ippdbPrintMetadatas(stdout, output, "p0PendingExp", !simple)) {
    173         psError(PS_ERR_UNKNOWN, false, "failed to print array");
     175        psError(PXTOOLS_ERR_PROG, false, "failed to print array");
    174176        psFree(output);
    175177        return false;
     
    188190    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
    189191    if (!status) {
    190         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit");
     192        psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
    191193        return false;
    192194    }
     
    194196    bool faulted = psMetadataLookupU64(&status, config->args, "-faulted");
    195197    if (!status) {
    196         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted");
     198        psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -faulted");
    197199        return false;
    198200    }
     
    231233
    232234    if (!p_psDBRunQuery(config->dbh, query)) {
    233         psError(PS_ERR_UNKNOWN, false, "database error");
     235        // XXX PS_EXIT_PROG_ERROR (incorrect SQL) or SYS_ERROR (database comms)
     236        psError(PXTOOLS_ERR_PROG, false, "database error");
    234237        psFree(query);
    235238        return false;
     
    239242    psArray *output = p_psDBFetchResult(config->dbh);
    240243    if (!output) {
    241         psError(PS_ERR_UNKNOWN, false, "database error");
     244        // XXX PS_EXIT_PROG_ERROR (incorrect SQL) or SYS_ERROR (database comms)
     245        psError(PXTOOLS_ERR_PROG, false, "database error");
    242246        return false;
    243247    }
    244248    if (!psArrayLength(output)) {
    245         // XXX check psError here
    246         psError(PS_ERR_UNKNOWN, false, "no pending newImfile rows found");
    247249        psFree(output);
    248250        return true;
     
    250252
    251253    bool simple = false;
    252     {
    253         bool status = false;
    254         simple = psMetadataLookupBool(&status, config->args, "-simple");
    255         if (!status) {
    256             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    257             return false;
    258         }
     254    simple = psMetadataLookupBool(&status, config->args, "-simple");
     255    if (!status) {
     256        psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -simple");
     257        return false;
    259258    }
    260259
    261260    // negate simple so the default is true
    262261    if (!ippdbPrintMetadatas(stdout, output, "newImfile", !simple)) {
    263         psError(PS_ERR_UNKNOWN, false, "failed to print array");
     262        psError(PXTOOLS_ERR_PROG, false, "failed to print array");
    264263        psFree(output);
    265264        return false;
     
    10941093    return raw;
    10951094}
    1096 
    1097 #if 0
    1098 static psU32 mapCodeStrToInt(const char *codeStr)
    1099 {
    1100     if (strcasestr(codeStr, "none")) {
    1101         return PX_ERROR_NONE;
    1102     } else if (strcasestr(codeStr, "unknown")) {
    1103         return PX_ERROR_UNKNOWN;
    1104     } else if (strcasestr(codeStr, "bad_data")) {
    1105         return PX_ERROR_BAD_DATA;
    1106     } else if (strcasestr(codeStr, "id10t")) {
    1107         return PX_ERROR_ID10T;
    1108     }
    1109 
    1110     psError(PS_ERR_UNKNOWN, true, "invalid fault code string");
    1111 
    1112     return (psU32) -1;
    1113 }
    1114 #endif
Note: See TracChangeset for help on using the changeset viewer.