home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / clipper / cuaclip.zip / ERRORSYS.PRG < prev    next >
Text File  |  1993-06-01  |  8KB  |  259 lines

  1. *COMMENTS***********************************************************************
  2. /*
  3. Copyright(C) Delcom-Deltranik International Software Engineering 1990-1993.
  4.  
  5. $owner: BILLW$
  6.  
  7. $version: 1.1$ $date: March 16, 1993$ $time: 01:57:38 PM$
  8.  
  9. */
  10. static id_string := "$id: ssvcid errorsys.prg 1.1 March 16, 1993 01:57:38 PM$";
  11. // $nokeywords$
  12. ********************************************************************************
  13.  
  14.  
  15.  
  16.  
  17. *PROTOTYPES**********************************************************************
  18. // Prototype Table
  19. // - PROCEDURE ErrorSys()
  20. // - STATIC FUNCTION DefError( e )
  21. // - STATIC FUNCTION ErrorMessage( e )
  22.  
  23. ********************************************************************************
  24.  
  25.  
  26.  
  27.  
  28. *PREPROCESSOR*******************************************************************
  29. #INCLUDE "error.ch"
  30. #INCLUDE "cuaclip.ch"
  31. #INCLUDE "mouse.ch"
  32.  
  33. // put messages to STDERR
  34. #COMMAND ? <list,...>   =>  ?? CHR( 13 ) + CHR( 10 ) ; ?? <list>
  35. #COMMAND ?? <list,...>  =>  OUTERR( <list> )
  36.  
  37.  
  38. // used below
  39. #DEFINE NTRIM( n )        ( LTRIM( STR( n ) ) )
  40. ********************************************************************************
  41.  
  42.  
  43.  
  44. *GLOBAL PROCEDURES**************************************************************
  45. //┌──────────────────────────────────────────────────────────────────────────┐
  46. //│  Description:                                                            │
  47. //│       Author: Bill Wilson                                                │
  48. //│ Date created: 01-13-93                                                   │
  49. //│ Time created: 12:14:17pm                                                 │
  50. //│    Copyright: Delcom International Software Engineering Inc.             │
  51. //├──────────────────────────────────────────────────────────────────────────┤
  52. //│    Procedure: ErrorSys()                                                 │
  53. //│                                                                          │
  54. //│    Arguments:                                                            │
  55. //│                                                                          │
  56. //│     See Also:                                                            │
  57. //│                                                                          │
  58. //└──────────────────────────────────────────────────────────────────────────┘
  59. PROCEDURE ErrorSys()
  60.  
  61.    MEMVAR PromptList
  62.    PUBLIC PromptList := {}
  63.  
  64.    ErrorBlock( {|e| DefError( e ) } )
  65.    InitMouse()
  66.    SetMousePos( ( MAXROW() / 2 ), ( MAXCOL() / 2 ) )
  67.  
  68. RETURN
  69. ********************************************************************************
  70.  
  71.  
  72.  
  73. *STATIC FUNCTIONS***************************************************************
  74. //┌──────────────────────────────────────────────────────────────────────────┐
  75. //│  Description:                                                            │
  76. //│       Author: Bill Wilson                                                │
  77. //│ Date created: 01-13-93                                                   │
  78. //│ Time created: 12:14:17pm                                                 │
  79. //│    Copyright: Delcom International Software Engineering Inc.             │
  80. //├──────────────────────────────────────────────────────────────────────────┤
  81. //│     Function: DefError()                                                 │
  82. //│                                                                          │
  83. //│    Arguments:                                                            │
  84. //│                                                                          │
  85. //│ Return Value:                                                            │
  86. //│     See Also:                                                            │
  87. //│                                                                          │
  88. //└──────────────────────────────────────────────────────────────────────────┘
  89. STATIC FUNCTION DefError( e )
  90.  
  91.    LOCAL i, cMessage, aOptions, nChoice, nOldMouse
  92.  
  93.    // by default, division by zero yields zero
  94.    IF ( e:genCode == EG_ZERODIV )
  95.       RETU ( 0 )
  96.    ENDIF
  97.  
  98.    // for network open error, set NETERR() and subsystem default
  99.    IF ( e:genCode == EG_OPEN .AND. e:osCode == 32 .AND. e:canDefault )
  100.  
  101.       NETERR( .t. )
  102.       RETU( .f. )                                // NOTE
  103.  
  104.    ENDIF
  105.  
  106.  
  107.    // for lock error during APPEND BLANK, set NETERR() and subsystem default
  108.    IF ( e:genCode == EG_APPENDLOCK .AND. e:canDefault )
  109.  
  110.       NETERR( .t. )
  111.       RETU( .f. )                                // NOTE
  112.  
  113.    ENDIF
  114.  
  115.  
  116.  
  117.    // build error message
  118.    cMessage := ErrorMessage( e )
  119.    altd()
  120.    // build options array
  121.    // aOptions := {"Break", "Quit"}
  122.    aOptions := { "Quit" }
  123.  
  124.    IF ( e:canRetry )
  125.       AAdd( aOptions, "Retry" )
  126.    ENDIF
  127.  
  128.    IF ( e:canDefault )
  129.       AADD( aOptions, "Default" )
  130.    ENDIF
  131.  
  132.  
  133.    FOR i := 1 TO 10
  134.       DISPEND()
  135.    NEXT
  136.  
  137.    // put up alert box
  138.    nChoice := 0
  139.    nOldMouse := SetMouse()
  140.    ClearMouse()
  141.    DO WHILE ( nChoice == 0 )
  142.       IF ( EMPTY( e:osCode ) )
  143.          nChoice := ALERT( cMessage, aOptions )
  144.  
  145.       ELSE
  146.          nChoice := ALERT( cMessage + ;
  147.          ";(DOS Error " + NTRIM(e:osCode) + ")", ;
  148.          aOptions )
  149.       ENDIF
  150.  
  151.  
  152.       IF ( nChoice == NIL )
  153.          EXIT
  154.       ENDIF
  155.  
  156.    ENDDO
  157.    InitMouse()
  158.    SetMouse( nOldMouse )
  159.    SetMousePos( MouseInRow(), MouseInCol() )
  160.  
  161.    IF ( !EMPTY( nChoice ) )
  162.  
  163.       // do as instructed
  164.       IF ( aOptions[ nChoice ] == "Break" )
  165.          BREAK( e )
  166.  
  167.       ELSEIF ( aOptions[ nChoice ] == "Retry" )
  168.          RETU( .t. )
  169.  
  170.       ELSEIF ( aOptions[ nChoice ] == "Default" )
  171.          RETU( .f. )
  172.  
  173.       ENDIF
  174.  
  175.    ENDIF
  176.  
  177.  
  178.    // display message and traceback
  179.    IF ( !Empty( e:osCode ) )
  180.       cMessage += " ( DOS Error " + NTRIM( e:osCode ) + ") "
  181.    ENDIF
  182.  
  183.    ? cMessage
  184.    i := 2
  185.    DO WHILE ( !EMPTY( ProcName( i ) ) )
  186.       ? "Called from", TRIM( PROCNAME( i ) ) + ;
  187.       "(" + NTRIM( PROCLINE( i ) ) + ")  "
  188.  
  189.       i++
  190.    ENDDO
  191.  
  192.  
  193.    // give up
  194.    ErrorLevel( 1 )
  195.    QUIT
  196.  
  197. RETURN (.f.)
  198.  
  199.  
  200.  
  201.  
  202. //┌──────────────────────────────────────────────────────────────────────────┐
  203. //│  Description:                                                            │
  204. //│       Author: Bill Wilson                                                │
  205. //│ Date created: 01-13-93                                                   │
  206. //│ Time created: 12:14:17pm                                                 │
  207. //│    Copyright: Delcom International Software Engineering Inc.             │
  208. //├──────────────────────────────────────────────────────────────────────────┤
  209. //│     Function: ErrorMessage()                                             │
  210. //│                                                                          │
  211. //│    Arguments:                                                            │
  212. //│                                                                          │
  213. //│ Return Value:                                                            │
  214. //│     See Also:                                                            │
  215. //│                                                                          │
  216. //└──────────────────────────────────────────────────────────────────────────┘
  217. STATIC FUNCTION ErrorMessage( e )
  218.  
  219.    LOCAL cMessage
  220.  
  221.    // start error message
  222.    cMessage := IF( e:severity > ES_WARNING, "Error ", "Warning " )
  223.  
  224.  
  225.    // add subsystem name if available
  226.    IF ( VALTYPE( e:subsystem ) == "C" )
  227.       cMessage += e:subsystem()
  228.    ELSE
  229.       cMessage += "???"
  230.    ENDIF
  231.  
  232.  
  233.    // add subsystem's error code if available
  234.    IF ( VALTYPE( e:subCode ) == "N" )
  235.       cMessage += ("/" + NTRIM( e:subCode ) )
  236.    ELSE
  237.       cMessage += "/???"
  238.    ENDIF
  239.  
  240.  
  241.    // add error description if available
  242.    IF ( VALTYPE( e:description ) == "C" )
  243.       cMessage += ( "  " + e:description )
  244.    ENDIF
  245.  
  246.  
  247.    // add either filename or operation
  248.    IF ( !EMPTY( e:filename ) )
  249.       cMessage += ( ": " + e:filename )
  250.  
  251.    ELSEIF ( !EMPTY( e:operation ) )
  252.       cMessage += ( ": " + e:operation )
  253.  
  254.    ENDIF
  255.  
  256.  
  257. RETURN (cMessage)
  258. ********************************************************************************
  259.