IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11086


Ignore:
Timestamp:
Jan 12, 2007, 4:28:16 PM (19 years ago)
Author:
eugene
Message:

fixed error codes

File:
1 edited

Legend:

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

    r11047 r11086  
    3030// this function can not fail -- exits on error
    3131pxConfig *p0toolConfig(pxConfig *config, int argc, char **argv) {
     32
     33    psExit exit_status = PS_EXIT_SUCCESS;
     34
    3235    if (!config) {
    3336        config = pxConfigAlloc();
     
    3740    config->modules = pmConfigRead(&argc, argv, NULL);
    3841    if (!config->modules) {
    39         psError(PS_ERR_UNKNOWN, false, "Can't find site configuration");
     42        psError(PXTOOLS_ERR_CONFIG, false, "Can't find site configuration");
    4043        goto FAIL;
    4144    }
     
    211214        psArgumentRemove (N, &argc, argv); \
    212215        if (config->mode) { \
    213             psError(PS_ERR_UNKNOWN, true, "only one mode selection is allowed"); \
     216            psError(PXTOOLS_ERR_CONFIG, true, "only one mode selection is allowed"); \
    214217            goto FAIL; \
    215218        } \
     
    218221    } \
    219222    if (!psMetadataAddMetadata(argSets, PS_LIST_TAIL, option, 0, NULL, argset)) {;\
    220         psError(PS_ERR_UNKNOWN, false, "failed to add argset for %s", option);\
     223        psError(PXTOOLS_ERR_PROG, false, "failed to add argset for %s", option);\
    221224    } \
    222225    psFree(argset); \
     
    236239    bool argErr = false;
    237240    if (config->mode == P0TOOL_MODE_NONE) {
     241        psError(PXTOOLS_ERR_CONFIG, false, "missing mode argument");
     242        fprintf (stderr, "mode argument is required\n");
    238243        argErr = true;
    239         fprintf (stderr, "mode argument is required\n");
    240244    } else if (! psArgumentParse(config->args, &argc, argv) || argc != 1) {
     245        psError(PXTOOLS_ERR_CONFIG, false, "unknown argument");
     246        fprintf (stderr, "error parsing arguments\n");
    241247        argErr = true;
    242         fprintf (stderr, "error parsing arguments\n");
    243248    }
    244249
     
    272277    if ((str = psMetadataLookupStr(&status, config->args, "-" #name))) { \
    273278        if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\
    274             psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
     279            psError(PXTOOLS_ERR_PROG, false, "failed to add item " #name); \
    275280            goto FAIL; \
    276281        } \
     
    288293        if ((str = psMetadataLookupStr(&status, config->args, "-inst"))) {
    289294            if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) {
    290                 psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
     295                psError(PXTOOLS_ERR_PROG, false, "failed to add item camera");
    291296                goto FAIL;
    292297            }
     
    300305        if ((imfiles = psMetadataLookupS32(&status, config->args, "-imfiles"))) {
    301306            if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "imfiles", 0, "==", imfiles)) {
    302                 psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles");
     307                psError(PXTOOLS_ERR_PROG, false, "failed to add item imfiles");
    303308                goto FAIL;
    304309            }
     
    318323    config->dbh = pmConfigDB(config->modules);
    319324    if (!config->dbh) {
    320         psError(PS_ERR_UNKNOWN, false, "Can't configure database");
     325        psError(PXTOOLS_ERR_SYS, false, "Can't configure database");
    321326        goto FAIL;
    322327    }
     
    330335
    331336FAIL:
     337    // use the top-most error to determine the exit status
     338    exit_status = pxerrorGetExitStatus();
     339
    332340    psFree(config);
    333341    pmConfigDone();
    334342    psLibFinalize();
    335     exit(EXIT_FAILURE);
     343    exit(exit_status);
    336344}
Note: See TracChangeset for help on using the changeset viewer.