IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 25, 2010, 12:09:45 PM (16 years ago)
Author:
Paul Price
Message:

Fixing error codes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAfileDefine.c

    r27000 r27084  
    9191    psMetadata *data = pmConfigFileRule(config, camera, name); // File rule
    9292    if (!data) {
    93         psError(PS_ERR_IO, true, "Can't find file rule %s!", name);
     93        psError(psErrorCodeLast(), false, "Can't find file rule %s!", name);
    9494        return NULL;
    9595    }
     
    105105    file->type = pmFPAfileTypeFromString(type);
    106106    if (file->type == PM_FPA_FILE_NONE) {
    107         psError(PS_ERR_IO, true, "FILE.TYPE is not defined for %s\n", name);
     107        psError(PM_ERR_CONFIG, true, "FILE.TYPE is not defined for %s\n", name);
    108108        psFree(file);
    109109        return NULL;
     
    115115    file->dataLevel = pmFPALevelFromName(psMetadataLookupStr (&status, data, "DATA.LEVEL"));
    116116    if (file->dataLevel == PM_FPA_LEVEL_NONE) {
    117         psError(PS_ERR_IO, true, "DATA.LEVEL is not set for %s\n", name);
     117        psError(PM_ERR_CONFIG, true, "DATA.LEVEL is not set for %s\n", name);
    118118        psFree(file);
    119119        return NULL;
     
    137137    if (!psMetadataAddPtr(config->files, PS_LIST_TAIL, name,
    138138                          PS_DATA_UNKNOWN | PS_META_DUPLICATE_OK, "", file)) {
    139         psError(PS_ERR_IO, false, "could not add %s to config files", name);
     139        psError(PM_ERR_CONFIG, false, "could not add %s to config files", name);
    140140        return NULL;
    141141    }
     
    167167        psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS"); // Known cameras
    168168        if (!mdok || !cameras) {
    169             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n");
     169            psError(PM_ERR_CONFIG, true, "Unable to find CAMERAS in the system configuration.\n");
    170170            return NULL;
    171171        }
    172172        camera = psMetadataLookupMetadata(&mdok, cameras, cameraName); // Camera configuration of interest
    173173        if (!mdok || !camera) {
    174             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find automatically generated "
    175                     "camera configuration %s in system configuration.\n", cameraName);
     174            psError(PM_ERR_CONFIG, true,
     175                    "Unable to find automatically generated camera configuration %s in system configuration.",
     176                    cameraName);
    176177            return NULL;
    177178        }
     
    184185    psMetadata *filerule = pmConfigFileRule(config, camera, name); // File rule
    185186    if (!filerule) {
    186         psError(PS_ERR_IO, true, "Can't find file rule %s!", name);
     187        psError(psErrorCodeLast(), false, "Can't find file rule %s!", name);
    187188        return NULL;
    188189    }
     
    199200    file->type = pmFPAfileTypeFromString(type);
    200201    if (file->type == PM_FPA_FILE_NONE) {
    201         psError(PS_ERR_IO, true, "FILE.TYPE is not defined for %s\n", name);
     202        psError(PM_ERR_CONFIG, true, "FILE.TYPE is not defined for %s\n", name);
    202203        psFree(file);
    203204        return NULL;
     
    230231    psMetadata *format = psMetadataLookupMetadata(&status, formats, formatName); // Camera format to use
    231232    if (!format) {
    232         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find format %s for file %s.\n",
     233        psError(PM_ERR_CONFIG, true, "Unable to find format %s for file %s.\n",
    233234                formatName, file->name);
    234235        psFree(file);
     
    287288                options->stdevNum = parseOptionFloat(scheme, "STDEV.NUM", source); // Padding to edge
    288289                if (!isfinite(options->stdevNum)) {
    289                     psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Bad value for STDEV.NUM for %s", source);
     290                    psError(PM_ERR_CONFIG, true, "Bad value for STDEV.NUM for %s", source);
    290291                    psFree(source);
    291292                    psFree(file);
     
    296297                options->stdevBits = parseOptionInt(scheme, "STDEV.BITS", source, 0); // Bits for stdev
    297298                if (options->stdevBits <= 0) {
    298                     psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Bad value for STDEV.BITS (%d) for %s",
     299                    psError(PM_ERR_CONFIG, true, "Bad value for STDEV.BITS (%d) for %s",
    299300                            options->stdevBits, source);
    300301                    psFree(source);
     
    337338    file->fileLevel = pmFPAPHULevel(format);
    338339    if (file->fileLevel == PM_FPA_LEVEL_NONE) {
    339         psError(PS_ERR_IO, true, "Unable to determine file level for %s\n", name);
     340        psError(PM_ERR_CONFIG, true, "Unable to determine file level for %s\n", name);
    340341        psFree(file);
    341342        return NULL;
     
    344345    file->dataLevel = pmFPALevelFromName(psMetadataLookupStr(&status, filerule, "DATA.LEVEL"));
    345346    if (file->dataLevel == PM_FPA_LEVEL_NONE) {
    346         psError(PS_ERR_IO, true, "DATA.LEVEL is not set for %s\n", name);
     347        psError(PM_ERR_CONFIG, true, "DATA.LEVEL is not set for %s\n", name);
    347348        psFree(file);
    348349        return NULL;
     
    443444        psString realName = pmConfigConvertFilename(filenames->data[0], config, false, false);
    444445        if (!realName) {
    445             psError(PS_ERR_IO, false, "Failed to convert file name %s", (char *)filenames->data[0]);
     446            psError(psErrorCodeLast(), false, "Failed to convert file name %s", (char *)filenames->data[0]);
    446447            return NULL;
    447448        }
     
    451452        psFits *fits = psFitsOpen(realName, "r"); // FITS file
    452453        if (!fits) {
    453             psError(PS_ERR_IO, false, "Failed to open file %s", realName);
     454            psError(psErrorCodeLast(), false, "Failed to open file %s", realName);
    454455            psFree(realName);
    455456            return NULL;
     
    457458        phu = psFitsReadHeader (NULL, fits); // Primary header
    458459        if (!phu) {
    459             psError(PS_ERR_IO, false, "Failed to read file header %s", realName);
     460            psError(psErrorCodeLast(), false, "Failed to read file header %s", realName);
    460461            psFree(realName);
    461462            return NULL;
     
    471472        format = pmConfigCameraFormatFromHeader(&camera, &cameraName, &formatName, config, phu, true);
    472473        if (!format) {
    473             psError(PS_ERR_IO, false, "Failed to determine camera format for %s", realName);
     474            psError(psErrorCodeLast(), false, "Failed to determine camera format for %s", realName);
    474475            psFree(camera);
    475476            psFree(formatName);
     
    481482        fileLevel = pmFPAPHULevel(format);
    482483        if (fileLevel == PM_FPA_LEVEL_NONE) {
    483             psError(PS_ERR_IO, true, "Unable to determine file level for %s", realName);
     484            psError(PM_ERR_CONFIG, true, "Unable to determine file level for %s", realName);
    484485            psFree(camera);
    485486            psFree(formatName);
     
    494495        psFree(camera);
    495496        if (!fpa) {
    496             psError(PS_ERR_IO, false, "Failed to construct FPA from %s", realName);
     497            psError(psErrorCodeLast(), false, "Failed to construct FPA from %s", realName);
    497498            psFree(formatName);
    498499            psFree(realName);
     
    508509    pmFPAfile *file = pmFPAfileDefineInput(config, fpa, cameraName, name); // File, to return
    509510    if (!file) {
    510         psError(PS_ERR_IO, false, "File %s not defined", name);
     511        psError(psErrorCodeLast(), false, "File %s not defined", name);
    511512        psFree(formatName);
    512513        psFree(format);
     
    535536            psString realName = pmConfigConvertFilename(filenames->data[i], config, false, false);
    536537            if (!realName) {
    537                 psError(PS_ERR_IO, false, "Failed to convert file name %s", (char*)filenames->data[i]);
     538                psError(psErrorCodeLast(), false, "Failed to convert file name %s", (char*)filenames->data[i]);
    538539                return NULL;
    539540            }
    540541            psFits *fits = psFitsOpen(realName, "r"); // FITS file
    541542            if (!fits) {
    542                 psError(PS_ERR_IO, false, "Failed to open file %s", realName);
     543                psError(psErrorCodeLast(), false, "Failed to open file %s", realName);
    543544                psFree(realName);
    544545                return NULL;
     
    551552            }
    552553            if (!phu) {
    553                 psError(PS_ERR_IO, false, "Failed to read file header %s", realName);
     554                psError(psErrorCodeLast(), false, "Failed to read file header %s", realName);
    554555                psFree(realName);
    555556                return NULL;
     
    560561        if (i == 0 && file->type == PM_FPA_FILE_MASK) {
    561562            if (!pmConfigMaskReadHeader(config, phu)) {
    562                 psError(PS_ERR_IO, false, "Error reading mask bits");
     563                psError(psErrorCodeLast(), false, "Error reading mask bits");
    563564                psFree(phu);
    564565                return NULL;
     
    570571                bool valid = false;
    571572                if (!pmConfigValidateCameraFormat(&valid, format, phu)) {
    572                     psError(PS_ERR_UNKNOWN, false, "Error in config scripts\n");
     573                    psError(psErrorCodeLast(), false, "Error in config scripts\n");
    573574                    psFree(phu);
    574575                    return NULL;
    575576                }
    576577                if (!valid) {
    577                     psError(PS_ERR_IO, false, "File %s is not from the required camera",
     578                    psError(psErrorCodeLast(), false, "File %s is not from the required camera",
    578579                            (char*)filenames->data[i]);
    579580                    psFree(phu);
     
    583584                format = pmConfigCameraFormatFromHeader(NULL, NULL, NULL, config, phu, true);
    584585                if (!format) {
    585                     psError(PS_ERR_IO, false, "Failed to determine camera format from %s",
     586                    psError(psErrorCodeLast(), false, "Failed to determine camera format from %s",
    586587                            (char*)filenames->data[i]);
    587588                    psFree(phu);
     
    609610        phu = NULL;
    610611        if (!view) {
    611             psError(PS_ERR_IO, false, "Unable to determine source for %s", name);
     612            psError(PM_ERR_CONFIG, true, "Unable to determine source for %s", name);
    612613            return NULL;
    613614        }
     
    641642    }
    642643    if (filenames->n == 0) {
    643         psError(PS_ERR_IO, false, "No files in array in %s in arguments", argname);
     644        psError(PM_ERR_CONFIG, true, "No files in array in %s in arguments", argname);
    644645        if (success) {
    645646            *success = false;
     
    675676    }
    676677    if (filenames->n == 0) {
    677         psError(PS_ERR_IO, false, "No files in array in %s in arguments", argname);
     678        psError(PM_ERR_CONFIG, true, "No files in array in %s in arguments", argname);
    678679        if (success) {
    679680            *success = false;
     
    708709    }
    709710    if (filenames->n <= entry) {
    710         psError(PS_ERR_IO, false, "Insufficient files (%ld) in array in %s in arguments",
     711        psError(PM_ERR_CONFIG, true, "Insufficient files (%ld) in array in %s in arguments",
    711712                filenames->n, argname);
    712713        if (success) {
     
    768769    }
    769770    if (bind && files->n != bind->n) {
    770         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     771        psError(PM_ERR_CONFIG, true,
    771772                "Length of filenames (%ld) and bind files (%ld) does not match.",
    772773                files->n, bind->n);
     
    782783        files->data[i] = psMemIncrRefCounter(fpaFileDefineFromArray(config, bindFile, filename, dummy));
    783784        if (!files->data[i]) {
    784             psError(PS_ERR_UNKNOWN, false, "Unable to define file %s %d", filename, i);
     785            psError(psErrorCodeLast(), false, "Unable to define file %s %d", filename, i);
    785786            psFree(dummy);
    786787            psFree(files);
     
    810811    // a camera config is needed (as source of file rule)
    811812    if (config->camera == NULL) {
    812         psError(PS_ERR_IO, true, "camera is not defined");
     813        psError(PM_ERR_PROG, true, "camera is not defined");
    813814        return NULL;
    814815    }
     
    817818    pmFPA *fpa = pmFPAConstruct(config->camera, config->cameraName);
    818819    if (!fpa) {
    819         psError(PS_ERR_IO, false, "Failed to construct FPA for %s", filename);
     820        psError(psErrorCodeLast(), false, "Failed to construct FPA for %s", filename);
    820821        return NULL;
    821822    }
     
    826827    psFree (fpa);
    827828    if (!file) {
    828         psError(PS_ERR_IO, false, "file %s not defined\n", filename);
     829        psError(psErrorCodeLast(), false, "file %s not defined\n", filename);
    829830        return NULL;
    830831    }
     
    832833    // image names may not come from file->names
    833834    if (!strcasecmp(file->filerule, "@FILES")) {
    834         psError(PS_ERR_IO, true, "supplied filerule uses illegal value @FILES");
     835        psError(PM_ERR_CONFIG, true, "supplied filerule uses illegal value @FILES");
    835836        // XXX remove the file from config->files
    836837        return NULL;
     
    889890    // a camera config is needed (as source of file rule)
    890891    if (config->camera == NULL) {
    891         psError(PS_ERR_IO, true, "camera is not defined");
     892        psError(PS_ERR_PROG, true, "camera is not defined");
    892893        return NULL;
    893894    }
     
    903904        fpa = pmFPAConstruct(config->camera, config->cameraName);
    904905        if (!fpa) {
    905             psError(PS_ERR_IO, false, "Failed to construct FPA for %s", filename);
     906            psError(psErrorCodeLast(), false, "Failed to construct FPA for %s", filename);
    906907            return NULL;
    907908        }
     
    910911        file = pmFPAfileDefineInput (config, fpa, NULL, filename);
    911912        if (!file) {
    912             psError(PS_ERR_IO, false, "file %s not defined\n", filename);
     913            psError(psErrorCodeLast(), false, "file %s not defined\n", filename);
    913914            psFree(fpa);
    914915            return NULL;
     
    942943    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, "PPIMAGE");
    943944    if (!status) {
    944         psError(PS_ERR_UNEXPECTED_NULL, true, "PPIMAGE recipe not found.");
     945        psError(PM_ERR_CONFIG, true, "PPIMAGE recipe not found.");
    945946        psFree(options);
    946947        psFree(fpa);
     
    10201021        pmDetrendSelectResults *results = pmDetrendSelect (options, config);
    10211022        if (!results) {
    1022             psError (PS_ERR_IO, false, "no matching detrend data");
     1023            psError (psErrorCodeLast(), false, "no matching detrend data");
    10231024            return NULL;
    10241025        }
     
    10261027        file->fileLevel = pmFPALevelFromName(results->level);
    10271028        if (file->fileLevel == PM_FPA_LEVEL_NONE) {
    1028             psError (PS_ERR_IO, false, "invalid file level for selected detrend data");
     1029            psError (PM_ERR_CONFIG, false, "invalid file level for selected detrend data");
    10291030            return NULL;
    10301031        }
     
    10511052    pmFPAfile *file = pmFPAfileDefineOutput (config, fpa, filename);
    10521053    if (!file) {
    1053         psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
     1054        psError(psErrorCodeLast(), false, "file %s not defined\n", filename);
    10541055        return NULL;
    10551056    }
     
    10701071    pmFPAfile *file = pmFPAfileDefineOutputForFormat(config, NULL, filename, src->cameraName, src->formatName);
    10711072    if (!file) {
    1072         psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
     1073        psError(psErrorCodeLast(), false, "file %s not defined\n", filename);
    10731074        return NULL;
    10741075    }
     
    10921093    pmFPAfile *file = pmFPAfileDefineOutput (config, NULL, filename);
    10931094    if (!file) {
    1094         psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
     1095        psError(psErrorCodeLast(), false, "file %s not defined\n", filename);
    10951096        return NULL;
    10961097    }
    10971098    if (!file->camera) {
    1098         psError(PS_ERR_UNEXPECTED_NULL, false, "file %s does not define a new camera\n", filename);
     1099        psError(PM_ERR_CONFIG, false, "file %s does not define a new camera\n", filename);
    10991100        return NULL;
    11001101    }
     
    11351136    }
    11361137    if (!file) {
    1137         psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
     1138        psError(PM_ERR_CONFIG, true, "file %s not defined\n", filename);
    11381139        return NULL;
    11391140    }
     
    11781179    }
    11791180    if (!file) {
    1180         psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
     1181        psError(PM_ERR_CONFIG, true, "file %s not defined\n", filename);
    11811182        return NULL;
    11821183    }
     
    11851186    if (src) {
    11861187        if (!pmConceptsCopyFPA(file->fpa, src, true, false)) {
    1187             psError(PS_ERR_UNKNOWN, false, "Unable to copy concepts from source to new FPA");
     1188            psError(psErrorCodeLast(), false, "Unable to copy concepts from source to new FPA");
    11881189            return NULL;
    11891190        }
     
    12291230    }
    12301231    if (!file) {
    1231         psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
     1232        psError(PM_ERR_CONFIG, true, "file %s not defined\n", filename);
    12321233        return NULL;
    12331234    }
     
    12361237    if (src) {
    12371238        if (!pmConceptsCopyFPA(file->fpa, src, false, false)) {
    1238             psError(PS_ERR_UNKNOWN, false, "Unable to copy concepts from source to new FPA");
     1239            psError(psErrorCodeLast(), false, "Unable to copy concepts from source to new FPA");
    12391240            return NULL;
    12401241        }
     
    12821283    }
    12831284    if (file == NULL) {
    1284         psError(PS_ERR_IO, true, "file %s is NULL", name);
     1285        psError(PM_ERR_CONFIG, true, "file %s is NULL", name);
    12851286        return false;
    12861287    }
Note: See TracChangeset for help on using the changeset viewer.