Documentation for Win32lib v0.70.18
Table of Contents

Errors

These routines are used to manage warnings and errors occurring as your program runs.


  • proc abortErr( sequence errorparam )   Display an error message, run any user-defined cleanup routines, and then abort.
  • proc attachCleanUp( routine_id )   Establishes a user defined clean up routine which is invoked just prior to win32lib ending or aborting.
  • proc detachCleanUp( routine_id )   Removes a user defined clean up routine from the list of attached ones.
  • proc setWarning( integer flag )   Shows or Hides warning messages from user.
  • proc warnErr( sequence errorparam )   Display an error message, with option to abort.

    Documentation for Win32lib v0.70.18
    Table of Contents

    [proc]
    abortErr
    ( sequence errorparam )

    Display an error message, run any user-defined cleanup routines, and then abort.

    Category: Errors

    errorparam can be either a text message or a two-element sequence in which the first is a text message and the second is an error code (integer).

    If any user-defined clean up routine have been attached, they are invoked prior to win32lib's own cleanup routine, then the application is aborted. See attachCleanUp() for details.

    Example:

           abortErr( {"The tape drive is not responding.", w32MsgNum + 17} )
    

    abortErr( "Fatal error. Bummer, dude." )

    See Also: attachCleanUp, detachCleanUp, setWarning, warnErr


    Documentation for Win32lib v0.70.18
    Table of Contents

    [proc]
    attachCleanUp
    ( routine_id )

    Establishes a user defined clean up routine which is invoked just prior to win32lib ending or aborting.

    Returns: (INTEGER) The number of clean up routines attached.

    Category: Errors

    Allows the application to clean up when win32lib application is ending or detects an abort situation. It is possible to attach multiple clean up routines. If this is done, they are invoked by win32lib in order of most-recently-attached to first-attached, that is in reverse order that they were attached in.

    The clean up routine, when invoked by win32lib, is passed four parameters...

  • ErrorCode (integer) Zero if this is a normal end, or the code number for the error that is causing win32lib to abort.
  • ErrorText (sequence) The text displayed to the user.
  • ControlId (integer) The id of the current control (0 => no control is current).
  • LastCleanup (integer) A flag which is 1 if this is the last user defined cleanup routine to be invoked, and 0 if there are others still to be invoked.

    The clean up routine must return an integer flag. If the flag is -1, then no further attached clean up routines will be invoked before win32lib aborts, otherwise any other routines will be invoked. You only return -1 if you really do know what the side-effects will be.

    The clean up routines are run before the crash_routines the program may have defined if using Euphoria v2.5 or higher.

    Example:

       function AppCleanUp(integer ErrCode, sequence ErrText, integer ControlId, integer LastCleanUp)
          . . .
          return 0 -- Continue with other clean up routines.
       end function
    

    -- Link in my clean-up routine cnt = attachCleanUp( routine_id("AppCleanUp" ))

    See Also: abortErr, detachCleanUp, setWarning, warnErr


    Documentation for Win32lib v0.70.18
    Table of Contents

    [proc]
    detachCleanUp
    ( routine_id )

    Removes a user defined clean up routine from the list of attached ones.

    Returns: If unsuccessful this returns -1, else the number of clean up routines still attached.

    Category: Errors

    Example:

       integer cnt, CU_id
       . . .
       function AppCleanUp(integer ErrCode, sequence ErrText, integer ControlId, integer LastCleanUp)
          . . .
          return 0 -- Continue with other clean up routines.
       end function
    

    -- Link in my clean-up routine CU_id = routine_id("AppCleanUp" ) cnt = attachCleanUp( CU_id ) . . . cnt = detachCleanUp( CU_id )

    See Also: abortErr, attachCleanUp, setWarning, warnErr


    Documentation for Win32lib v0.70.18
    Table of Contents

    [proc]
    setWarning
    ( integer flag )

    Shows or Hides warning messages from user.

    Category: Errors

    Since 'warning' messages (triggered by warnErr) are only warnings and not fatal, it may be advantageous to suppress them in an application.

    The flag maybe one of ...

  • 0 To hide warning messages
  • 1 To show warning messages, giving the option to continue or quit.
  • 2 To turn all warning messages into fatal errors instead.

    By default, the setting is 1 Example:

          -- suppress warning messages
          setWarning( 0 )
    

    See Also: abortErr, attachCleanUp, detachCleanUp, warnErr


    Documentation for Win32lib v0.70.18
    Table of Contents

    [proc]
    warnErr
    ( sequence errorparam )

    Display an error message, with option to abort.

    Category: Errors

    errorparam can be either a text message or a two-element sequence in which the first is a text message and the second is an error code (integer).

    This routine will display a dialog window with three buttons.
    [ YES ] : If selected, the program will continue.
    [ NO ] : if pressed, the program will continue, but future warning about the same error will be ignored.
    [CANCEL]: if pressed, will stop the program running immediately.

    If any user-defined clean up routine have been attached, they are invoked prior to win32lib's own cleanup routine, if the application is aborted. See attachCleanUp() for details. Example:

          warnErr( "Bad data. Abort program?" )
    

    See Also: abortErr, attachCleanUp, detachCleanUp, setWarning