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/ppStack.c

    r23341 r27004  
    1515int main(int argc, char *argv[])
    1616{
    17     psExit exitValue = PS_EXIT_SUCCESS; // Exit value
     17    psLibInit(NULL);
    1818    psTimerStart(TIMER_NAME);
    1919    psTimerStart("PPSTACK_STEPS");
    20     psLibInit(NULL);
    2120
    2221    pmConfig *config = pmConfigRead(&argc, argv, PPSTACK_RECIPE); // Configuration
    2322    if (!config) {
    24         psErrorStackPrint(stderr, "Error reading configuration.");
    25         exitValue = PS_EXIT_CONFIG_ERROR;
    26         goto die;
    27     }
    28 
    29     (void) psTraceSetLevel("ppStack", 5);
    30 
    31     if (!ppStackArgumentsSetup(argc, argv, config)) {
    32         psErrorStackPrint(stderr, "Error reading arguments.\n");
    33         exitValue = PS_EXIT_CONFIG_ERROR;
    3423        goto die;
    3524    }
     
    3827
    3928    if (!pmModelClassInit()) {
    40         psErrorStackPrint(stderr, "Error initialising model classes.\n");
    41         exitValue = PS_EXIT_PROG_ERROR;
     29        psError(PPSTACK_ERR_PROG, false, "Unable to initialise model classes.");
    4230        goto die;
    4331    }
    4432
    4533    if (!psphotInit()) {
    46         psErrorStackPrint(stderr, "Error initialising psphot.\n");
    47         exitValue = PS_EXIT_PROG_ERROR;
     34        psError(PPSTACK_ERR_PROG, false, "Error initialising psphot.");
     35        goto die;
     36    }
     37
     38    (void)psTraceSetLevel("ppStack", 5);
     39
     40    if (!ppStackArgumentsSetup(argc, argv, config)) {
    4841        goto die;
    4942    }
    5043
    5144    if (!ppStackCamera(config)) {
    52         psErrorStackPrint(stderr, "Error setting up input files.\n");
    53         exitValue = PS_EXIT_CONFIG_ERROR;
    5445        goto die;
    5546    }
    5647
    5748    if (!ppStackArgumentsParse(config)) {
    58         psErrorStackPrint(stderr, "Error reading arguments.\n");
    59         exitValue = PS_EXIT_CONFIG_ERROR;
    6049        goto die;
    6150    }
    6251
    6352    if (!ppStackLoop(config)) {
    64         psErrorStackPrint(stderr, "Error performing combination.\n");
    65         exitValue = PS_EXIT_DATA_ERROR;
    6653        goto die;
    6754    }
     
    7865    psLibFinalize();
    7966    pmVisualClose();
     67
     68    psExit exitValue = PS_EXIT_SUCCESS;        // Exit value for program
     69    psErrorCode errorCode = psErrorCodeLast(); // Error code
     70    if (errorCode != PS_ERR_NONE) {
     71        psErrorStackPrint(stderr, "Unable to perform stack.");
     72        switch (errorCode) {
     73          case PPSTACK_ERR_UNKNOWN:
     74          case PS_ERR_UNKNOWN:
     75            exitValue = PS_EXIT_UNKNOWN_ERROR;
     76            break;
     77          case PS_ERR_IO:
     78          case PS_ERR_DB_CLIENT:
     79          case PS_ERR_DB_SERVER:
     80          case PS_ERR_BAD_FITS:
     81          case PS_ERR_OS_CALL_FAILED:
     82          case PPSTACK_ERR_IO:
     83            exitValue = PS_EXIT_SYS_ERROR;
     84            break;
     85          case PS_ERR_BAD_PARAMETER_VALUE:
     86          case PS_ERR_BAD_PARAMETER_TYPE:
     87          case PS_ERR_BAD_PARAMETER_NULL:
     88          case PS_ERR_BAD_PARAMETER_SIZE:
     89          case PPSTACK_ERR_ARGUMENTS:
     90          case PPSTACK_ERR_CONFIG:
     91            exitValue = PS_EXIT_CONFIG_ERROR;
     92            break;
     93          case PPSTACK_ERR_PSF:
     94          case PPSTACK_ERR_REJECTED:
     95          case PPSTACK_ERR_DATA:
     96            exitValue = PS_EXIT_DATA_ERROR;
     97            break;
     98          case PS_ERR_UNEXPECTED_NULL:
     99          case PS_ERR_PROGRAMMING:
     100          case PPSTACK_ERR_NOT_IMPLEMENTED:
     101          case PPSTACK_ERR_PROG:
     102          default:
     103            // It's a programming error if we're not dealing with the error correctly
     104            exitValue = PS_EXIT_PROG_ERROR;
     105            break;
     106        }
     107    }
     108
    80109    exit(exitValue);
    81110}
Note: See TracChangeset for help on using the changeset viewer.