IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27083


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

Fixing error codes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfig.c

    r27060 r27083  
    178178        char *envName = envStart + 1;   // Start of the environment variable name
    179179        if (envName[0] == '\0') {
    180             psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Path %s contains a bad environment variable.\n", dir);
     180            psError(PM_ERR_CONFIG, true, "Path %s contains a bad environment variable.\n", dir);
    181181            return NULL;
    182182        }
     
    184184            envName++;
    185185            if (envName[0] == '\0') {
    186                 psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     186                psError(PM_ERR_CONFIG, true,
    187187                        "Path %s contains a bad environment variable.\n", dir);
    188188                return NULL;
     
    276276
    277277    if (configPath == NULL) {
    278         psError(PS_ERR_IO, true, "Cannot find %s configuration file (%s) in path\n", description, name);
     278        psError(PM_ERR_CONFIG, true, "Cannot find %s configuration file (%s) in path\n", description, name);
    279279        return false;
    280280    }
     
    300300    }
    301301
    302     psError(PS_ERR_IO, true, "Cannot find %s configuration file %s in path\n", description, name);
     302    psError(PM_ERR_CONFIG, true, "Cannot find %s configuration file %s in path\n", description, name);
    303303    return false;
    304304
     
    306306    *config = psMetadataConfigRead(NULL, &numBadLines, realName, true);
    307307    if (numBadLines > 0) {
    308         psError(PS_ERR_IO, false, "%d bad lines in %s configuration file (%s)",
     308        psError(PM_ERR_CONFIG, false, "%d bad lines in %s configuration file (%s)",
    309309                numBadLines, description, realName);
    310310        psFree (realName);
     
    313313    }
    314314    if (!*config) {
    315         psError(PS_ERR_IO, true, "Unable to read %s configuration from %s",
     315        psError(PM_ERR_CONFIG, true, "Unable to read %s configuration from %s",
    316316                description, realName);
    317317        psFree (realName);
     
    332332    }
    333333    if (item->type != PS_DATA_STRING) {
    334         psTrace("config", 2, "Element %s in %s metadata is not of type STR.\n",
     334        psError(PM_ERR_CONFIG, true, "Element %s in %s metadata is not of type STR.\n",
    335335                item->name, description);
    336336        return false;
     
    340340    psMetadata *new = NULL;         // New metadata
    341341    if (!pmConfigFileRead(&new, item->data.str, item->name)) {
    342         psError(PM_ERR_CONFIG, false, "Trouble reading reading %s %s.\n",
     342        psError(psErrorCodeLast(), false, "Trouble reading reading %s %s.\n",
    343343                description, item->name);
    344344        psFree(new);
     
    365365    while ((item = psMetadataGetAndIncrement(iter))) {
    366366        if (!pmConfigFileIngest(item, description)) {
    367             psError(PM_ERR_CONFIG, false, "Unable to read %s %s.", description, item->name);
     367            psError(psErrorCodeLast(), false, "Unable to read %s %s.", description, item->name);
    368368            psFree(iter);
    369369            return false;
     
    386386    psMetadata *formats = psMetadataLookupMetadata(&mdok, camera, "FORMATS"); // Formats
    387387    if (!mdok || !formats) {
    388         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find FORMATS in camera configuration %s.\n", name);
     388        psError(PM_ERR_CONFIG, true, "Unable to find FORMATS in camera configuration %s.\n", name);
    389389        return false;
    390390    }
    391391    if (!metadataReadFiles(formats, "camera format")) {
    392         psError(PS_ERR_UNKNOWN, false, "Unable to read formats within camera configuration %s.\n", name);
     392        psError(psErrorCodeLast(), false, "Unable to read formats within camera configuration %s.\n", name);
    393393        return false;
    394394    }
     
    490490    psMetadataItem *siteItem = psMetadataLookup(config->user, "SITE");
    491491    if (!siteItem) {
    492         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find SITE in user configuration.");
     492        psError(PM_ERR_CONFIG, true, "Unable to find SITE in user configuration.");
    493493        psFree(config);
    494494        return NULL;
    495495    }
    496496    if (!pmConfigFileIngest(siteItem, "site configuration")) {
    497         psError(PS_ERR_UNKNOWN, false, "Unable to read site configuration");
     497        psError(psErrorCodeLast(), false, "Unable to read site configuration");
    498498        psFree(config);
    499499        return NULL;
     
    504504    psMetadataItem *systemItem = psMetadataLookup(config->user, "SYSTEM");
    505505    if (!systemItem) {
    506         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find SYSTEM in user configuration.");
     506        psError(PM_ERR_CONFIG, true, "Unable to find SYSTEM in user configuration.");
    507507        psFree(config);
    508508        return NULL;
    509509    }
    510510    if (!pmConfigFileIngest(systemItem, "system configuration")) {
    511         psError(PS_ERR_UNKNOWN, false, "Unable to read system configuration");
     511        psError(psErrorCodeLast(), false, "Unable to read system configuration");
    512512        psFree(config);
    513513        return NULL;
     
    665665                seed = strtoll(argv[argNum], &end, 0);
    666666                if (strlen(end) > 0) {
    667                     psError(PS_ERR_IO, true, "Unable to read random number generator seed: %s", argv[argNum]);
     667                    psError(PM_ERR_CONFIG, true, "Unable to read random number generator seed: %s",
     668                            argv[argNum]);
    668669                    psFree(config);
    669670                    return NULL;
     
    690691            psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS");
    691692            if (!cameras) {
    692                 psError(PS_ERR_IO, false, "Unable to find CAMERAS in site configuration.\n");
     693                psError(PM_ERR_CONFIG, false, "Unable to find CAMERAS in site configuration.\n");
    693694                psFree(config);
    694695                return NULL;
     
    698699            char *cameraFile = psMetadataLookupStr(&mdok, cameras, cameraName); // The filename
    699700            if (!cameraFile) {
    700                 psError(PS_ERR_IO, false, "%s is not listed in the site CAMERAS list\n", cameraName);
     701                psError(PM_ERR_CONFIG, false, "%s is not listed in the site CAMERAS list\n", cameraName);
    701702                psFree(config);
    702703                return NULL;
     
    705706            // load this camera's configuration informatoin
    706707            if (!pmConfigFileRead(&config->camera, cameraFile, "camera")) {
    707                 psError(PM_ERR_CONFIG, false, "Problem reading %s", cameraName);
     708                psError(psErrorCodeLast(), false, "Problem reading %s", cameraName);
    708709                psFree(config);
    709710                return NULL;
     
    716717            // Read in the formats
    717718            if (!cameraReadFormats(config->camera, cameraFile)) {
    718                 psError(PS_ERR_UNKNOWN, false, "Unable to read formats within camera configuration %s.\n",
     719                psError(psErrorCodeLast(), false, "Unable to read formats within camera configuration %s.\n",
    719720                        cameraFile);
    720721                psFree(config);
     
    724725            // Read in any camera-specific calibrations
    725726            if (!cameraReadCalibrations(config->camera, cameraName)) {
    726                 psError(PS_ERR_UNKNOWN, false,
     727                psError(psErrorCodeLast(), false,
    727728                        "Unable to read calibrations within camera configuration %s.\n",
    728729                        cameraName);
     
    735736
    736737            if (!pmConfigCameraSkycellVersion(config->system, cameraName)) {
    737                 psError(PS_ERR_UNKNOWN, false,
     738                psError(psErrorCodeLast(), false,
    738739                        "Unable to generate skycell versions of specified camera %s.\n",
    739740                        cameraName);
     
    743744
    744745            if (!pmConfigCameraMosaickedVersions(config->system, cameraName)) {
    745                 psError(PS_ERR_UNKNOWN, false,
     746                psError(psErrorCodeLast(), false,
    746747                        "Unable to generate mosaicked versions of specified camera %s.\n",
    747748                        cameraName);
     
    757758        psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS"); // List of cameras
    758759        if (!mdok || !cameras) {
    759             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n");
     760            psError(PM_ERR_CONFIG, true, "Unable to find CAMERAS in the system configuration.\n");
    760761            return false;
    761762        }
    762763
    763764        if (!metadataReadFiles(cameras, "camera configuration")) {
    764             psError(PS_ERR_UNKNOWN, false, "Unable to read cameras within system configuration.\n");
     765            psError(psErrorCodeLast(), false, "Unable to read cameras within system configuration.\n");
    765766            psFree(config);
    766767            return NULL;
     
    790791
    791792        if (!pmConfigCameraSkycellVersionsAll(config->system)) {
    792             psError(PS_ERR_UNKNOWN, false, "Unable to generate skycell versions of cameras.\n");
     793            psError(psErrorCodeLast(), false, "Unable to generate skycell versions of cameras.\n");
    793794            psFree(config);
    794795            return NULL;
    795796        }
    796797        if (!pmConfigCameraMosaickedVersionsAll(config->system)) {
    797             psError(PS_ERR_UNKNOWN, false, "Unable to generate mosaicked versions of cameras.\n");
     798            psError(psErrorCodeLast(), false, "Unable to generate mosaicked versions of cameras.\n");
    798799            psFree(config);
    799800            return NULL;
     
    803804    // Load the recipes from the camera file, if appropriate
    804805    if(!pmConfigReadRecipes(config, PM_RECIPE_SOURCE_SYSTEM | PM_RECIPE_SOURCE_CAMERA)) {
    805         psError(PS_ERR_IO, false, "Failed to read recipes from camera file");
     806        psError(psErrorCodeLast(), false, "Failed to read recipes from camera file");
    806807        psFree(config);
    807808        return NULL;
     
    818819
    819820    if (!pmConfigReadRecipes(config, PM_RECIPE_SOURCE_CL)) {
    820         psError(PS_ERR_IO, false, "Failed to read recipes from command-line");
     821        psError(psErrorCodeLast(), false, "Failed to read recipes from command-line");
    821822        psFree(config);
    822823        return NULL;
     
    827828        psArgumentRemove(argNum, argc, argv);
    828829        if (argNum + 1 >= *argc) {
    829             psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     830            psError(PM_ERR_CONFIG, true,
    830831                    "Filerule switch (-F) provided without old and new filerule.");
    831832            psFree(config);
     
    840841        psMetadata *cameras = psMetadataLookupMetadata(NULL, config->system, "CAMERAS"); // List of cameras
    841842        if (!cameras) {
    842             psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find CAMERAS in the site configuration.\n");
     843            psError(PM_ERR_CONFIG, false, "Unable to find CAMERAS in the site configuration.\n");
    843844            return false;
    844845        }
     
    10011002    psMetadata *rule = psMetadataLookupMetadata(&mdStatus, cameraFormat, "RULE");
    10021003    if (! mdStatus || ! rule) {
    1003         psError(PS_ERR_UNKNOWN, false, "Unable to read rule for camera.");
     1004        psError(PM_ERR_CONFIG, false, "Unable to read rule for camera.");
    10041005        *valid = false;
    10051006        return false;
     
    10101011    psArray *keys = psListToArray (keyList);
    10111012    if (! keys) {
    1012         psError(PS_ERR_UNKNOWN, false, "Unable to read rule for camera.");
     1013        psError(PM_ERR_CONFIG, false, "Unable to read rule for camera.");
    10131014        *valid = false;
    10141015        return false;
     
    10591060        }
    10601061
    1061         psError(PS_ERR_UNKNOWN, false, "Invalid type for RULE %s.", ruleItem->name);
     1062        psError(PM_ERR_CONFIG, false, "Invalid type for RULE %s.", ruleItem->name);
    10621063        *valid = false;
    10631064        psFree (keyList);
     
    10941095    psMetadata *formats = psMetadataLookupMetadata(&mdok, camera, "FORMATS"); // List of formats
    10951096    if (!mdok || !formats) {
    1096         psError(PS_ERR_UNKNOWN, false, "Unable to find list of FORMATS in camera %s", cameraName);
     1097        psError(PM_ERR_CONFIG, false, "Unable to find list of FORMATS in camera %s", cameraName);
    10971098        *status = false;
    10981099        return false;
     
    11001101
    11011102    if (!metadataReadFiles(formats, "camera format")) {
    1102         psError(PS_ERR_UNKNOWN, false, "Unable to read cameras formats within camera configuration.\n");
     1103        psError(psErrorCodeLast(), false, "Unable to read cameras formats within camera configuration.\n");
    11031104        *status = false;
    11041105        return false;
     
    11161117        bool valid = false;
    11171118        if (!pmConfigValidateCameraFormat(&valid, testFormat, header)) {
    1118             psError (PS_ERR_UNKNOWN, false, "Error in config scripts for camera %s, format %s\n",
     1119            psError (psErrorCodeLast(), false, "Error in config scripts for camera %s, format %s\n",
    11191120                     cameraName, formatsItem->name);
    11201121            *status = false;
     
    11621163        psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS");
    11631164        if (! mdok || !cameras) {
    1164             psError(PS_ERR_IO, true, "Unable to find CAMERAS in the configuration.");
     1165            psError(PM_ERR_CONFIG, true, "Unable to find CAMERAS in the configuration.");
    11651166            return NULL;
    11661167        }
    11671168
    11681169        if (!metadataReadFiles(cameras, "camera configuration")) {
    1169             psError(PS_ERR_UNKNOWN, false, "Unable to read cameras within site configuration.\n");
     1170            psError(psErrorCodeLast(), false, "Unable to read cameras within site configuration.\n");
    11701171            return NULL;
    11711172        }
     
    11961197            } else {
    11971198                if (!status) {
    1198                     psError(PS_ERR_IO, false, "Error reading camera config data for %s", camerasItem->name);
     1199                    psError(psErrorCodeLast(), false, "Error reading camera config data for %s",
     1200                            camerasItem->name);
    11991201                    return NULL;
    12001202                }
     
    12051207        // Done looking at all cameras
    12061208        if (!config->camera) {
    1207             psError(PS_ERR_IO, false, "Unable to find a camera that matches input FITS header!");
     1209            psError(PM_ERR_CONFIG, true, "Unable to find a camera that matches input FITS header!");
    12081210            return NULL;
    12091211        }
     
    12111213        // Now we have the camera, we can read the recipes
    12121214        if (readRecipes && !pmConfigReadRecipes(config, PM_RECIPE_SOURCE_CAMERA | PM_RECIPE_SOURCE_CL)) {
    1213             psError(PS_ERR_IO, false, "Error reading recipes from camera config for %s", config->cameraName);
     1215            psError(psErrorCodeLast(), false, "Error reading recipes from camera config for %s",
     1216                    config->cameraName);
    12141217            return NULL;
    12151218        }
     
    12871290
    12881291    if (!found) {
    1289         psError(PS_ERR_IO, true, "Unable to find a format with the specified camera (%s) that matches the "
    1290                 "given header.\n", baseName);
     1292        psError(PM_ERR_CONFIG, true,
     1293                "Unable to find a format with the specified camera (%s) that matches the given header.",
     1294                baseName);
    12911295        psFree (baseName);
    12921296        return NULL;
     
    13191323    psMetadata *cameras = psMetadataLookupMetadata(NULL, config->system, "CAMERAS");
    13201324    if (!cameras) {
    1321         psError(PS_ERR_IO, true, "Unable to find CAMERAS in the configuration.");
     1325        psError(PM_ERR_CONFIG, true, "Unable to find CAMERAS in the configuration.");
    13221326        return NULL;
    13231327    }
     
    13251329    psMetadataItem *item = psMetadataLookup(cameras, cameraName); // Item with camera of interest
    13261330    if (!pmConfigFileIngest(item, "camera configuration")) {
    1327         psError(PS_ERR_UNKNOWN, false, "Unable to ingest camera configuration.");
     1331        psError(psErrorCodeLast(), false, "Unable to ingest camera configuration.");
    13281332        return NULL;
    13291333    }
     
    13411345        item = psMetadataLookup(config->site, name);
    13421346        if (!item) {
    1343             psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     1347            psError(PM_ERR_CONFIG, true,
    13441348                    "Unable to find %s in user or site configuration", name);
    13451349            return NULL;
     
    13471351    }
    13481352    if (item->type != type) {
    1349         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     1353        psError(PM_ERR_CONFIG, true,
    13501354                "Type of %s (%x) in user/site configuration does not match expected (%x)",
    13511355                name, item->type, type);
     
    13641368#ifndef HAVE_PSDB
    13651369
    1366     psError(PS_ERR_UNKNOWN, false,
     1370    psError(PM_ERR_PROG, false,
    13671371            "Cannot configure database: psModules was compiled without database support.");
    13681372    return NULL;
     
    14131417    psMetadata *rules = psMetadataLookupMetadata(&mdok, format, "RULE"); // How to identify this format
    14141418    if (!mdok || !rules) {
    1415         psError(PS_ERR_IO, true, "Unable to find RULE in camera format.\n");
     1419        psError(PM_ERR_CONFIG, true, "Unable to find RULE in camera format.\n");
    14161420        return false;
    14171421    }
     
    14211425    while ((rulesItem = psMetadataGetAndIncrement(rulesIter))) {
    14221426        if (!PS_DATA_IS_PRIMITIVE(rulesItem->type) && rulesItem->type != PS_DATA_STRING) {
    1423             psError(PS_ERR_UNKNOWN, false, "Invalid type for RULE %s.", rulesItem->name);
     1427            psError(PM_ERR_CONFIG, false, "Invalid type for RULE %s.", rulesItem->name);
    14241428            return false;
    14251429        }
     
    14531457          case PS_METADATA_ITEM_COMPARE_OP_NE:
    14541458            // It's not at all obvious what the value should be, so return an error.
    1455             psError(PS_ERR_IO, true,
     1459            psError(PM_ERR_CONFIG, true,
    14561460                    "RULE %s (defined by an OPeration) is not present or not consistent in output header",
    14571461                    rulesItem->name);
     
    15361540              default:
    15371541                // rigid format, no comments allowed?
    1538                 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to parse file list: spaces detected.");
     1542                psError(PM_ERR_CONFIG, true, "Unable to parse file list: spaces detected.");
    15391543                psFree(input);
    15401544                fclose(f);
     
    15691573    if (!files) {
    15701574        psAbort("error parsing argument list");
    1571         psError(PS_ERR_IO, false, "error parsing argument list");
     1575        psError(psErrorCodeLast(), false, "error parsing argument list");
    15721576        psFree (files);
    15731577        return false;
     
    16241628        psMetadata *datapath = psMetadataLookupPtr (NULL, config->site, "DATAPATH");
    16251629        if (datapath == NULL) {
    1626             psError(PS_ERR_UNKNOWN, true, "DATAPATH is not defined in config.site");
     1630            psError(PM_ERR_CONFIG, true, "DATAPATH is not defined in config.site");
    16271631            psFree (newName);
    16281632            return NULL;
     
    16321636        char *mark = strchr (point, '/');
    16331637        if (mark == NULL) {
    1634             psError(PS_ERR_UNKNOWN, true, "syntax error in PATH-style name %s", newName);
     1638            psError(PM_ERR_CONFIG, true, "syntax error in PATH-style name %s", newName);
    16351639            psFree (newName);
    16361640            return false;
     
    16401644        char *realpath = psMetadataLookupStr (NULL, datapath, path);
    16411645        if (realpath == NULL) {
    1642             psError(PS_ERR_UNKNOWN, true,
     1646            psError(PM_ERR_CONFIG, true,
    16431647                    "path (%s) not defined in config.site:DATAPATH for PATH-style name %s",
    16441648                    path, newName);
     
    16561660        if (!checkPath(newName, create, trunc)) {
    16571661            // let checkPath()'s psError() call float up
    1658             psError(PS_ERR_UNKNOWN, false, "error from checkPath for path:// (%s)", newName);
     1662            psError(psErrorCodeLast(), false, "error from checkPath for path:// (%s)", newName);
    16591663            psFree (newName);
    16601664            return NULL;
     
    17471751    psMetadataItem *item = psMetadataLookup(camera, "FILERULES"); // Item with the file rule of interest
    17481752    if (!item) {
    1749         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find FILERULES in the camera configuration.");
     1753        psError(PM_ERR_CONFIG, false, "Unable to find FILERULES in the camera configuration.");
    17501754        return NULL;
    17511755    }
     
    17801784    psMetadataItem *item = psMetadataLookup(camera, "FITSTYPES"); // Item with the file rule of interest
    17811785    if (!item) {
    1782         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find FITSTYPES in the camera configuration.");
     1786        psError(PM_ERR_CONFIG, false, "Unable to find FITSTYPES in the camera configuration.");
    17831787        return NULL;
    17841788    }
Note: See TracChangeset for help on using the changeset viewer.