IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 18, 2010, 6:42:01 PM (16 years ago)
Author:
Paul Price
Message:

Reworked ppStack to be better about error codes and their translation to exit codes.

Location:
trunk/ppStack/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src

    • Property svn:ignore
      •  

        old new  
        1010stamp-h1
        1111ppStackVersionDefinitions.h
         12ppStackErrorCodes.c
         13ppStackErrorCodes.h
  • trunk/ppStack/src/ppStackCamera.c

    r26898 r27004  
    3030        pmFPAfileDefineFromArgs(&found, config, name, "FILENAMES");
    3131    if (!file || !found) {
    32         psError(PS_ERR_UNKNOWN, false, "Unable to define file %s from %s", name, filename);
     32        psError(psErrorCodeLast(), false, "Unable to define file %s from %s", name, filename);
    3333        return NULL;
    3434    }
    3535    if (file->type != type) {
    36         psError(PS_ERR_IO, true, "%s is not of type %s", name, pmFPAfileStringFromType(type));
     36        psError(PS_ERR_IO, PPSTACK_ERR_CONFIG, "%s is not of type %s", name, pmFPAfileStringFromType(type));
    3737        return NULL;
    3838    }
     
    5353    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe for ppSim
    5454    if (!recipe) {
    55         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE);
     55        psError(PPSTACK_ERR_CONFIG, false, "Unable to find recipe %s", PPSTACK_RECIPE);
    5656        return false;
    5757    }
     
    6767                                                           "PPSTACK.INPUT.MASK"); // Input masks
    6868        if (!status) {
    69             psError(PS_ERR_UNKNOWN, false, "Unable to define input masks from RUN metadata.");
     69            psError(psErrorCodeLast(), false, "Unable to define input masks from RUN metadata.");
    7070            psFree(runImages);
    7171            return false;
     
    7676                                                          "PPSTACK.INPUT.VARIANCE"); // Input variances
    7777        if (!status) {
    78             psError(PS_ERR_UNKNOWN, false, "Unable to define input variances from RUN metadata.");
     78            psError(psErrorCodeLast(), false, "Unable to define input variances from RUN metadata.");
    7979            psFree(runImages);
    8080            return false;
     
    8888                                                         "PPSTACK.INPUT.SOURCES"); // Input sources
    8989        if (!status) {
    90             psError(PS_ERR_UNKNOWN, false, "Unable to define input sources from RUN metadata.");
     90            psError(psErrorCodeLast(), false, "Unable to define input sources from RUN metadata.");
    9191            psFree(runImages);
    9292            return false;
    9393        }
    9494        if (!runSrc) {
    95             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to define input sources from RUN metadata.");
     95            psError(PPSTACK_ERR_CONFIG, true, "Unable to define input sources from RUN metadata.");
    9696            psFree(runImages);
    9797            return false;
     
    104104                                                         "PPSTACK.INPUT.PSF"); // Input PSFs
    105105                if (!status) {
    106                     psError(PS_ERR_UNKNOWN, false, "Unable to define input PSFs from RUN metadata.");
     106                    psError(psErrorCodeLast(), false, "Unable to define input PSFs from RUN metadata.");
    107107                    psFree(runImages);
    108108                    return false;
     
    118118                                                                    "PPSTACK.CONV.KERNEL"); // Conv'n kernels
    119119                if (!status) {
    120                     psError(PS_ERR_UNKNOWN, false, "Unable to define convolution kernels from RUN metadata.");
     120                    psError(psErrorCodeLast(), false,
     121                            "Unable to define convolution kernels from RUN metadata.");
    121122                    psFree(runImages);
    122123                    return false;
    123124                }
    124125                if (!runKernel) {
    125                     psError(PS_ERR_UNEXPECTED_NULL, true,
     126                    psError(PPSTACK_ERR_CONFIG, true,
    126127                            "Unable to define convolution kernels from RUN metadata.");
    127128                    psFree(runImages);
     
    137138        psMetadata *inputs = psMetadataLookupMetadata(NULL, config->arguments, "INPUTS"); // The inputs info
    138139        if (!inputs) {
    139             psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find inputs.");
     140            psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to find inputs.");
    140141            return false;
    141142        }
     
    145146        while ((item = psMetadataGetAndIncrement(iter))) {
    146147            if (item->type != PS_DATA_METADATA) {
    147                 psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     148                psError(PPSTACK_ERR_ARGUMENTS, true,
    148149                        "Component %s of the input metadata is not of type METADATA", item->name);
    149150                psFree(iter);
     
    155156            psString image = psMetadataLookupStr(NULL, input, "IMAGE"); // Name of image
    156157            if (!image || strlen(image) == 0) {
    157                 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Component %s lacks IMAGE of type STR", item->name);
     158                psError(PPSTACK_ERR_ARGUMENTS, true, "Component %s lacks IMAGE of type STR", item->name);
    158159                psFree(iter);
    159160                return false;
     
    169170                                              image, PM_FPA_FILE_IMAGE); // File for image
    170171            if (!imageFile) {
    171                 psError(PS_ERR_UNKNOWN, false, "Unable to define file from image %d (%s)", i, image);
     172                psError(psErrorCodeLast(), false, "Unable to define file from image %d (%s)", i, image);
    172173                return false;
    173174            }
     
    175176            if (mask && strlen(mask) > 0 &&
    176177                !defineFile(config, imageFile, "PPSTACK.INPUT.MASK", mask, PM_FPA_FILE_MASK)) {
    177                 psError(PS_ERR_UNKNOWN, false, "Unable to define file from mask %d (%s)", i, mask);
     178                psError(psErrorCodeLast(), false, "Unable to define file from mask %d (%s)", i, mask);
    178179                return false;
    179180            }
     
    183184                if (!defineFile(config, imageFile, "PPSTACK.INPUT.VARIANCE", variance,
    184185                                PM_FPA_FILE_VARIANCE)) {
    185                     psError(PS_ERR_UNKNOWN, false,
     186                    psError(psErrorCodeLast(), false,
    186187                            "Unable to define file from variance %d (%s)", i, variance);
    187188                    return false;
     
    195196                    havePSFs = true;
    196197                    if (!defineFile(config, imageFile, "PPSTACK.INPUT.PSF", psf, PM_FPA_FILE_PSF)) {
    197                         psError(PS_ERR_UNKNOWN, false, "Unable to define file from psf %d (%s)", i, psf);
     198                        psError(psErrorCodeLast(), false, "Unable to define file from psf %d (%s)", i, psf);
    198199                        return false;
    199200                    }
    200201                }
    201202            } else if (havePSFs) {
    202                 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find PSF %d", i);
     203                psError(PPSTACK_ERR_CONFIG, true, "Unable to find PSF %d", i);
    203204                return false;
    204205            }
    205206
    206207            if (!sources || strlen(sources) == 0) {
    207                 psError(PS_ERR_UNEXPECTED_NULL, true, "SOURCES not provided for file %d", i);
     208                psError(PPSTACK_ERR_CONFIG, true, "SOURCES not provided for file %d", i);
    208209                return false;
    209210            }
    210211            if (!defineFile(config, imageFile, "PPSTACK.INPUT.SOURCES", sources, PM_FPA_FILE_CMF)) {
    211                 psError(PS_ERR_UNKNOWN, false, "Unable to define file from sources %d (%s)",
     212                psError(psErrorCodeLast(), false, "Unable to define file from sources %d (%s)",
    212213                        i, sources);
    213214                return false;
     
    217218                pmFPAfile *kernel = pmFPAfileDefineOutput(config, imageFile->fpa, "PPSTACK.CONV.KERNEL");
    218219                if (!kernel) {
    219                     psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.CONV.KERNEL"));
     220                    psError(psErrorCodeLast(), false,
     221                            "Unable to generate output file from PPSTACK.CONV.KERNEL");
    220222                    return false;
    221223                }
     
    235237    pmFPA *outFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain the output
    236238    if (!outFPA) {
    237         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to construct an FPA from camera configuration.");
     239        psError(psErrorCodeLast(), false, "Unable to construct an FPA from camera configuration.");
    238240        return false;
    239241    }
     
    241243    psFree(outFPA);                        // Drop reference
    242244    if (!output) {
    243         psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT"));
     245        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT"));
    244246        return false;
    245247    }
    246248    if (output->type != PM_FPA_FILE_IMAGE) {
    247         psError(PS_ERR_IO, true, "PPSTACK.OUTPUT is not of type IMAGE");
     249        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT is not of type IMAGE");
    248250        return false;
    249251    }
     
    251253
    252254    if (!pmFPAAddSourceFromFormat(outFPA, "Stack", output->format)) {
    253         psError(PS_ERR_UNKNOWN, false, "Unable to generate output FPA.");
     255        psError(psErrorCodeLast(), false, "Unable to generate output FPA.");
    254256        return false;
    255257    }
     
    258260    pmFPAfile *outMask = pmFPAfileDefineOutput(config, output->fpa, "PPSTACK.OUTPUT.MASK");
    259261    if (!outMask) {
    260         psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT.MASK"));
     262        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.MASK"));
    261263        return false;
    262264    }
    263265    if (outMask->type != PM_FPA_FILE_MASK) {
    264         psError(PS_ERR_IO, true, "PPSTACK.OUTPUT.MASK is not of type MASK");
     266        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.MASK is not of type MASK");
    265267        return false;
    266268    }
     
    271273        pmFPAfile *outVariance = pmFPAfileDefineOutput(config, output->fpa, "PPSTACK.OUTPUT.VARIANCE");
    272274        if (!outVariance) {
    273             psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT.VARIANCE"));
     275            psError(psErrorCodeLast(), false, "Unable to generate output file from PPSTACK.OUTPUT.VARIANCE");
    274276            return false;
    275277        }
    276278        if (outVariance->type != PM_FPA_FILE_VARIANCE) {
    277             psError(PS_ERR_IO, true, "PPSTACK.OUTPUT.VARIANCE is not of type VARIANCE");
     279            psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.VARIANCE is not of type VARIANCE");
    278280            return false;
    279281        }
     
    284286        pmFPAfile *targetPSF = pmFPAfileDefineOutput(config, output->fpa, "PPSTACK.TARGET.PSF");
    285287        if (!targetPSF) {
    286             psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.TARGET.PSF"));
     288            psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.TARGET.PSF"));
    287289            return false;
    288290        }
    289291        if (targetPSF->type != PM_FPA_FILE_PSF) {
    290             psError(PS_ERR_IO, true, "PPSTACK.TARGET.PSF is not of type PSF");
     292            psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.TARGET.PSF is not of type PSF");
    291293            return false;
    292294        }
     
    298300    pmFPA *unconvFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain unconvolved output
    299301    if (!unconvFPA) {
    300         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to construct an FPA from camera configuration.");
     302        psError(psErrorCodeLast(), false, "Unable to construct an FPA from camera configuration.");
    301303        return false;
    302304    }
     
    304306    psFree(unconvFPA);                  // Drop reference
    305307    if (!unConv) {
    306         psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.UNCONV"));
     308        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.UNCONV"));
    307309        return false;
    308310    }
    309311    if (unConv->type != PM_FPA_FILE_IMAGE) {
    310         psError(PS_ERR_IO, true, "PPSTACK.UNCONV is not of type IMAGE");
     312        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV is not of type IMAGE");
    311313        return false;
    312314    }
     
    314316
    315317    if (!pmFPAAddSourceFromFormat(unconvFPA, "Stack", unConv->format)) {
    316         psError(PS_ERR_UNKNOWN, false, "Unable to generate output FPA.");
     318        psError(psErrorCodeLast(), false, "Unable to generate output FPA.");
    317319        return false;
    318320    }
     
    321323    pmFPAfile *unconvMask = pmFPAfileDefineOutput(config, unconvFPA, "PPSTACK.UNCONV.MASK");
    322324    if (!unconvMask) {
    323         psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.UNCONV.MASK"));
     325        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.UNCONV.MASK"));
    324326        return false;
    325327    }
    326328    if (unconvMask->type != PM_FPA_FILE_MASK) {
    327         psError(PS_ERR_IO, true, "PPSTACK.UNCONV.MASK is not of type MASK");
     329        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV.MASK is not of type MASK");
    328330        return false;
    329331    }
     
    334336        pmFPAfile *unconvVariance = pmFPAfileDefineOutput(config, unconvFPA, "PPSTACK.UNCONV.VARIANCE");
    335337        if (!unconvVariance) {
    336             psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.UNCONV.VARIANCE"));
     338            psError(psErrorCodeLast(), false, "Unable to generate output file from PPSTACK.UNCONV.VARIANCE");
    337339            return false;
    338340        }
    339341        if (unconvVariance->type != PM_FPA_FILE_VARIANCE) {
    340             psError(PS_ERR_IO, true, "PPSTACK.UNCONV.VARIANCE is not of type VARIANCE");
     342            psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV.VARIANCE is not of type VARIANCE");
    341343            return false;
    342344        }
     
    348350    pmFPAfile *jpeg1 = pmFPAfileDefineOutput(config, NULL, "PPSTACK.OUTPUT.JPEG1");
    349351    if (!jpeg1) {
    350         psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG1"));
     352        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG1"));
    351353        return false;
    352354    }
    353355    if (jpeg1->type != PM_FPA_FILE_JPEG) {
    354         psError(PS_ERR_IO, true, "PPSTACK.OUTPUT.JPEG1 is not of type JPEG");
     356        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.JPEG1 is not of type JPEG");
    355357        return false;
    356358    }
     
    358360    pmFPAfile *jpeg2 = pmFPAfileDefineOutput(config, NULL, "PPSTACK.OUTPUT.JPEG2");
    359361    if (!jpeg2) {
    360         psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG2"));
     362        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG2"));
    361363        return false;
    362364    }
    363365    if (jpeg2->type != PM_FPA_FILE_JPEG) {
    364         psError(PS_ERR_IO, true, "PPSTACK.OUTPUT.JPEG2 is not of type JPEG");
     366        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.JPEG2 is not of type JPEG");
    365367        return false;
    366368    }
     
    377379        pmFPAfile *psphotInput = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.INPUT");
    378380        if (!psphotInput) {
    379             psError(PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.INPUT"));
    380             return false;
    381         }
    382         // specify the number of psphot input images
    383         psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1);
     381            psError(psErrorCodeLast(), false, _("Unable to generate output file from PSPHOT.INPUT"));
     382            return false;
     383        }
     384        // specify the number of psphot input images
     385        psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1);
    384386
    385387        // Define associated psphot input/output files
    386388        if (!psphotDefineFiles(config, psphotInput)) {
    387             psError(PSPHOT_ERR_CONFIG, false,
     389            psError(psErrorCodeLast(), false,
    388390                    "Trouble defining the additional input/output files for psphot");
    389391            return false;
     
    393395        pmFPAfile *outPSF = pmFPAfileDefineOutputFromFile(config, output, "PSPHOT.PSF.SAVE");
    394396        if (!outPSF) {
    395             psError(PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.PSF.SAVE"));
     397            psError(psErrorCodeLast(), false, _("Unable to generate output file from PSPHOT.PSF.SAVE"));
    396398            return false;
    397399        }
    398400        if (outPSF->type != PM_FPA_FILE_PSF) {
    399             psError(PS_ERR_IO, true, "PSPHOT.PSF.SAVE is not of type PSF");
     401            psError(PPSTACK_ERR_CONFIG, true, "PSPHOT.PSF.SAVE is not of type PSF");
    400402            return false;
    401403        }
Note: See TracChangeset for help on using the changeset viewer.