IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 25, 2010, 4:26:50 PM (16 years ago)
Author:
Paul Price
Message:

Reworking error codes to get consistent exit codes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pswarp/src/pswarpCleanup.c

    r21323 r27096  
    1313# include "pswarp.h"
    1414
    15 void pswarpCleanup (pmConfig *config) {
     15psExit pswarpCleanup (pmConfig *config)
     16{
     17    psExit exitValue = PS_EXIT_SUCCESS;        // Exit value for program
     18    psErrorCode errorCode = psErrorCodeLast(); // Error code
     19    if (errorCode != PS_ERR_NONE) {
     20        psErrorStackPrint(stderr, "Unable to perform warp.");
     21        switch (errorCode) {
     22          case PSWARP_ERR_UNKNOWN:
     23          case PS_ERR_UNKNOWN:
     24            exitValue = PS_EXIT_UNKNOWN_ERROR;
     25            break;
     26          case PS_ERR_IO:
     27          case PS_ERR_DB_CLIENT:
     28          case PS_ERR_DB_SERVER:
     29          case PS_ERR_BAD_FITS:
     30          case PS_ERR_OS_CALL_FAILED:
     31          case PSWARP_ERR_IO:
     32            exitValue = PS_EXIT_SYS_ERROR;
     33            break;
     34          case PS_ERR_BAD_PARAMETER_VALUE:
     35          case PS_ERR_BAD_PARAMETER_TYPE:
     36          case PS_ERR_BAD_PARAMETER_NULL:
     37          case PS_ERR_BAD_PARAMETER_SIZE:
     38          case PSWARP_ERR_ARGUMENTS:
     39          case PSWARP_ERR_CONFIG:
     40            exitValue = PS_EXIT_CONFIG_ERROR;
     41            break;
     42          case PSWARP_ERR_DATA:
     43          case PSWARP_ERR_NO_OVERLAP:
     44            exitValue = PS_EXIT_DATA_ERROR;
     45            break;
     46          case PS_ERR_UNEXPECTED_NULL:
     47          case PS_ERR_PROGRAMMING:
     48          case PSWARP_ERR_NOT_IMPLEMENTED:
     49          default:
     50            // It's a programming error if we're not dealing with the error correctly
     51            exitValue = PS_EXIT_PROG_ERROR;
     52            break;
     53        }
     54    }
    1655
    17     psFree (config);
     56    psThreadPoolFinalize();
     57    psMemCheckCorruption(stderr, true);
    1858
    19     psTimerStop ();
    20     psMemCheckCorruption(stderr, true);
    21     pmModelClassCleanup ();
    22     psTimeFinalize ();
    23     psThreadPoolFinalize ();
    24     pmConceptsDone ();
    25     pmConfigDone ();
    26     // fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "pswarp");
    27     fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "pswarp");
     59    psFree(config);
    2860
    29     return;
     61    psTimerStop();
     62    pmVisualClose();
     63    pmModelClassCleanup();
     64    pmConceptsDone();
     65    pmConfigDone();
     66    psLibFinalize();
     67
     68    return exitValue;
    3069}
Note: See TracChangeset for help on using the changeset viewer.