Jump to content

DosRaiseException: Difference between revisions

From EDM2
Created page with "==Description== Raises an exception for the current thread. ==Syntax== <PRE> #define INCL_DOSEXCEPTIONS #include <os2.h> PEXCEPTIONREPORTRECORD pexcept; /* A pointer to..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Description==
Raises an exception for the current thread.
Raises an exception for the current thread.


==Syntax==
==Syntax==
<PRE>
  DosRaiseException(pexcept)
#define INCL_DOSEXCEPTIONS
#include <os2.h>
 
PEXCEPTIONREPORTRECORD    pexcept;  /*  A pointer to an exception report record that contains exception-specific information needed for the exception to be raised. */
APIRET                    ulrc;    /* Return Code. */
 
ulrc = DosRaiseException(pexcept);


</PRE>
==Parameters==
==Parameters==
; pexcept (PEXCEPTIONREPORTRECORD) - input : A pointer to an exception report record that contains exception-specific information needed for the exception to be raised.
;pexcept ([[PEXCEPTIONREPORTRECORD]]) - input: A pointer to an exception report record that contains exception-specific information needed for the exception to be raised.
:The pointer to the exception report record, as well as certain handler flags in the structure, are supplied by the system.


The pointer to the exception report record, as well as certain handler flags in the structure, are supplied by the system.
==Return Code==
==Return Code==
ulrc (APIRET) - returns
;ulrc (APIRET) - returns:DosRaiseException returns the following value:
 
*0 NO_ERROR
DosRaiseException returns the following value:
 
*0   NO_ERROR
 


==Remarks==
==Remarks==
Note: Do not make Presentation Manager calls from exception handlers.
Note: Do not make Presentation Manager calls from exception handlers.


DosRaiseException enables a thread to raise a synchronous exception that has been deferred from a must-complete section.  
DosRaiseException enables a thread to raise a synchronous exception that has been deferred from a must-complete section.


DosRaiseException can also be used to simulate an asynchronous or synchronous exception.
DosRaiseException can also be used to simulate an asynchronous or synchronous exception.
Line 88: Line 75:
   return XCPT_CONTINUE_SEARCH;
   return XCPT_CONTINUE_SEARCH;
}
}
</PRE>


</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosAcknowledgeSignalException|DosAcknowledgeSignalException]]
* [[DosAcknowledgeSignalException]]
* [[OS2 API:CPI:DosEnterMustComplete|DosEnterMustComplete]]
* [[DosEnterMustComplete]]
* [[OS2 API:CPI:DosExitMustComplete|DosExitMustComplete]]
* [[DosExitMustComplete]]
* [[OS2 API:CPI:DosSendSignalException|DosSendSignalException]]
* [[DosSendSignalException]]
* [[OS2 API:CPI:DosSetExceptionHandler|DosSetExceptionHandler]]
* [[DosSetExceptionHandler]]
* [[OS2 API:CPI:DosSetSignalExceptionFocus|DosSetSignalExceptionFocus]]
* [[DosSetSignalExceptionFocus]]
* [[OS2 API:CPI:DosUnsetExceptionHandler|DosUnsetExceptionHandler]]
* [[DosUnsetExceptionHandler]]
* [[OS2 API:CPI:DosUnwindException|DosUnwindException]]
* [[DosUnwindException]]
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 11:46, 26 June 2021

Raises an exception for the current thread.

Syntax

DosRaiseException(pexcept)

Parameters

pexcept (PEXCEPTIONREPORTRECORD) - input
A pointer to an exception report record that contains exception-specific information needed for the exception to be raised.
The pointer to the exception report record, as well as certain handler flags in the structure, are supplied by the system.

Return Code

ulrc (APIRET) - returns
DosRaiseException returns the following value:
  • 0 NO_ERROR

Remarks

Note: Do not make Presentation Manager calls from exception handlers.

DosRaiseException enables a thread to raise a synchronous exception that has been deferred from a must-complete section.

DosRaiseException can also be used to simulate an asynchronous or synchronous exception.

Example Code

This example shows how to raise an exception for the current thread.

#define INCL_DOSPROCESS       /* DOS process values (for DosSleep) */
#define INCL_DOSEXCEPTIONS    /* DOS exception values */
#define INCL_ERRORS           /* DOS error values     */
#include <os2.h>
#include <stdio.h>

ULONG _System MyTermHandler( PEXCEPTIONREPORTRECORD       p1,
                             PEXCEPTIONREGISTRATIONRECORD p2,
                             PCONTEXTRECORD               p3,
                             PVOID                        pv );
int main (VOID)
{
  EXCEPTIONREGISTRATIONRECORD RegRec  = {0};     /* Exception Registration Record */
  APIRET      rc      = NO_ERROR;   /* Return code                   */

  /* Add MyTermHandler to this thread's chain of exception handlers */

  RegRec.ExceptionHandler = (ERR)MyTermHandler;
  rc = DosSetExceptionHandler( &RegRec );
  if (rc != NO_ERROR) {
     printf("DosSetExceptionHandler error: return code = %u\n",rc);
     return 1;
  }

  printf("Terminate this program using Ctrl-C or Ctrl-Break.\n");

  rc = DosSleep(60000L);   /* Give user plenty of time to comply... */

  rc = DosUnsetExceptionHandler( &RegRec );
  if (rc != NO_ERROR) {
     printf("DosUnsetExceptionHandler error: return code = %u\n",rc);
     return 1;
  }
  return NO_ERROR;
}
/***********************************************************************/
ULONG _System MyTermHandler( PEXCEPTIONREPORTRECORD       p1,
                             PEXCEPTIONREGISTRATIONRECORD p2,
                             PCONTEXTRECORD               p3,
                             PVOID                        pv )
{
  APIRET  rc = NO_ERROR;

  printf("*** MyTermHandler entered: ExceptionNum = %x\n",p1->ExceptionNum);

  rc = DosUnsetExceptionHandler( p2 );  /* Stop recursive entry to handler */
  rc = DosRaiseException( p1 );         /* Exception Report Record */
  if (rc != NO_ERROR) {
     printf("DosRaiseException error:  return code = %u\n", rc);
  }

  return XCPT_CONTINUE_SEARCH;
}

Related Functions