IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 2, 2006, 3:02:08 PM (20 years ago)
Author:
Paul Price
Message:

Applying RHL patch. Generally improves the error handling and traceback. pmConcepts.c and pmConceptsRead.c done by PAP (RHL did this also, but I had already done them). Resolved conflicts, except for pmFPAfile.c, which uses psAbort in some instances where RHL's patch had psError; leave this for Gene to decide.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/concepts/pmConceptsStandard.c

    r7281 r7311  
    6969                    sscanf(concept->data.V, "%d %d %f", &big, &medium, &small) != 3)
    7070            {
    71                 psError(PS_ERR_IO, true, "Cannot interpret FPA.RA: %s\n", concept->data.V);
     71                psError(PS_ERR_UNKNOWN, true, "Cannot interpret FPA.RA: %s\n", concept->data.V);
    7272                break;
    7373            }
     
    8080        break;
    8181    default:
    82         psError(PS_ERR_IO, true, "%s concept is of an unexpected type: %x\n", pattern->name, concept->type);
     82        psError(PS_ERR_UNKNOWN, true, "%s concept is of an unexpected type: %x\n", pattern->name, concept->type);
    8383        return NULL;
    8484    }
     
    171171    assert(pattern);
    172172
    173     psRegion *trimsec = psAlloc(sizeof(psRegion)); // Make space for a psRegion (usually passed by value)
     173    psRegion *trimsec = psRegionAlloc(0, 0, 0, 0);
    174174
    175175    if (concept->type != PS_DATA_STRING) {
    176         psError(PS_ERR_IO, true, "CELL.TRIMSEC after read is not of type STR (%x)\n", concept->type);
    177         *trimsec = psRegionSet(0.0, 0.0, 0.0, 0.0);
     176        psError(PS_ERR_UNKNOWN, true, "CELL.TRIMSEC after read is not of type STR (%x)\n", concept->type);
    178177    } else {
    179178        *trimsec = psRegionFromString(concept->data.V);
     
    231230        }
    232231    default:
    233         psError(PS_ERR_IO, true, "CELL.BIASSEC after read is not of type STRING or LIST --- assuming "
     232        psError(PS_ERR_UNKNOWN, true, "CELL.BIASSEC after read is not of type STRING or LIST --- assuming "
    234233                "blank.\n");
    235234    }
     
    259258                    (strcmp(pattern->name, "CELL.YBIN") == 0 && sscanf(binString, "%*d %d", &binning) != 1 &&
    260259                     sscanf(binString, "%*d,%d", &binning) != 1)) {
    261                 psError(PS_ERR_IO, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);
     260                psError(PS_ERR_UNKNOWN, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);
    262261            }
    263262        }
     
    269268        TYPE_CASE(binning, concept, S32);
    270269    default:
    271         psError(PS_ERR_IO, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name,
     270        psError(PS_ERR_UNKNOWN, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name,
    272271                concept->type);
    273272    }
     
    290289    psString sys = concept->data.V;     // The time system string
    291290    if (concept->type != PS_DATA_STRING || strlen(sys) <= 0) {
    292         psError(PS_ERR_IO, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");
     291        psError(PS_ERR_UNKNOWN, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");
    293292    } else if (strcasecmp(sys, "TAI") == 0) {
    294293        timeSys = PS_TIME_TAI;
     
    300299        timeSys = PS_TIME_TT;
    301300    } else {
    302         psError(PS_ERR_IO, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");
     301        psError(PS_ERR_UNKNOWN, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");
    303302    }
    304303
     
    334333    // Get format
    335334    psMetadata *formats = psMetadataLookupMD(&mdok, cameraFormat, "FORMATS");
    336     if (!mdok || !formats)
     335    if (!mdok || !formats) {
     336        psError(PS_ERR_UNKNOWN, false, "Unable to find FORMATS in camera configuration.\n");
    337337        return NULL;
     338    }
    338339
    339340    psString timeFormat = psMetadataLookupStr(&mdok, formats, "CELL.TIME");
    340     if (!mdok || !timeFormat || !strlen(timeFormat))
     341    if (!mdok || !timeFormat || !strlen(timeFormat)) {
     342        psError(PS_ERR_UNKNOWN, false, "Unable to find CELL.TIME in FORMATS.\n");
    341343        return NULL;
     344    }
    342345
    343346    // Parse the time format
     
    385388            psMetadataItem *timeItem = psListGet(dateTime, PS_LIST_HEAD + 1); // Item containing the time
    386389            if (dateItem->type != PS_DATA_STRING) {
    387                 psError(PS_ERR_IO, true, "Date is not of type STR.\n");
     390                psError(PS_ERR_UNKNOWN, true, "Date is not of type STR.\n");
    388391                return NULL;
    389392            }
     
    392395            if (sscanf(dateString, "%d-%d-%d", &year, &month, &day) != 3 &&
    393396                    sscanf(dateString, "%d/%d/%d", &year, &month, &day) != 3) {
    394                 psError(PS_ERR_IO, true, "Unable to read date: %s\n", dateString);
     397                psError(PS_ERR_UNKNOWN, true, "Unable to read date: %s\n", dateString);
    395398                return NULL;
    396399            }
     
    408411                year = temp;
    409412            }
    410             if (pre2000Time || year < 2000) {
    411                 year += 2000;
    412             }
     413            if (year < 100) {
     414                if (pre2000Time) {
     415                    year += 1900;
     416                } else {
     417                    year += 2000;
     418                }
     419            }
     420            sprintf(dateString,"%04d-%02d-%02d", year, month, day);
     421
    413422            psString timeString = NULL; // The string with the time
    414423            if (timeItem->type == PS_DATA_STRING) {
     
    427436                    TYPE_CASE(seconds, timeItem, F64);
    428437                default:
    429                     psError(PS_ERR_IO, true, "Time is not of an expected type: %x\n", timeItem->type);
     438                    psError(PS_ERR_UNKNOWN, true, "Time is not of an expected type: %x\n", timeItem->type);
    430439                    return NULL;
    431440                }
     
    440449            psStringAppend(&dateTimeString, "%sT%s", dateString, timeString);
    441450            time = psTimeFromISO(dateTimeString, timeSys);
     451            psFree(dateTimeString);
    442452            break;
    443453        }
     
    463473                time = psTimeFromMJD(timeValue);
    464474            } else {
    465                 psError(PS_ERR_IO, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n", timeValue);
     475                psError(PS_ERR_UNKNOWN, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n",
     476                        timeValue);
    466477                time = psTimeFromJD(timeValue);
    467478            }
     
    475486                time = psTimeFromMJD(timeValue);
    476487            } else {
    477                 psError(PS_ERR_IO, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n", timeValue);
     488                psError(PS_ERR_UNKNOWN, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n",
     489                        timeValue);
    478490                time = psTimeFromJD(timeValue);
    479491            }
     
    481493        }
    482494    default:
    483         psError(PS_ERR_IO, true, "Unable to parse CELL.TIME.\n");
     495        psError(PS_ERR_UNKNOWN, true, "Unable to parse CELL.TIME.\n");
    484496        return NULL;
    485497    }
     
    526538        TYPE_CASE(offset, concept, S32);
    527539    default:
    528         psError(PS_ERR_IO, true, "Concept %s is not of integer type, as expected.\n", pattern->name);
     540        psError(PS_ERR_UNKNOWN, true, "Concept %s is not of integer type, as expected.\n", pattern->name);
    529541        return NULL;
    530542    }
     
    724736        // XXX: Couldn't be bothered doing these right now
    725737        if (pre2000Time) {
    726             psError(PS_ERR_IO, true, "Don't you realise it's the twenty-first century?\n");
     738            psError(PS_ERR_UNKNOWN, true, "Don't you realise it's the twenty-first century?\n");
    727739            return NULL;
    728740        }
    729741        if (backwardsTime) {
    730             psError(PS_ERR_IO, true, "You want it BACKWARDS?  Not right now, thanks.\n");
     742            psError(PS_ERR_UNKNOWN, true, "You want it BACKWARDS?  Not right now, thanks.\n");
    731743            return NULL;
    732744        }
    733745        if (usaTime) {
    734             psError(PS_ERR_IO, true, "USA?  No OK --- yet.\n");
     746            psError(PS_ERR_UNKNOWN, true, "USA?  No OK.\n");
    735747            return NULL;
    736748        }
     
    778790
    779791    if (concept->type != PS_TYPE_S32) {
    780         psError(PS_ERR_IO, true, "Concept %s is not of type S32, as expected.\n", concept->name);
     792        psError(PS_ERR_UNKNOWN, true, "Concept %s is not of type S32, as expected.\n", concept->name);
    781793        return NULL;
    782794    }
Note: See TracChangeset for help on using the changeset viewer.