From EDM2
Jump to: navigation, search

Disables or enables error notification to end users for errors in the current process.




error (ULONG) - input 
Error and Exception pop-up flags.
The unused high-order bits are reserved, and must be zero. The following values can be specified for this parameter. They can be combined using the "logical or" ( | ) operator.
FERR_DISABLEHARDERR (0x00000000) Disable hard error pop-ups.
FERR_ENABLEHARDERR (0x00000001) Enable hard error pop-ups.
FERR_ENABLEEXCEPTION (0x00000000) Enable program exception and untrapped numeric-processor exception pop-ups.
FERR_DISABLEEXCEPTION (0x00000002) Disable program exception and untrapped numeric-processor exception pop-ups.

Return Code

ulrc (APIRET) - returns

DosError returns one of the following values:

  • 0 NO_ERROR


DosError disables or enables end-user notification of hard errors, program exceptions, or untrapped, numeric-processor exceptions for the current process. This affects the notifications for all threads in the current process.

The CONFIG.SYS statements AUTOFAIL=ON and SUPPRESSPOPUPS=x can be used to disable these notifications for all processes in the system.

If DosError is not issued, and AUTOFAIL=ON and SUPPRESSPOPUPS=x have not been specified in CONFIG.SYS, user notification for hard errors and exceptions is enabled.

There is no corresponding function to query the current status of error notification. Care should be taken if this function is used in a DLL, since the caller may have already disabled end-user error notifications and the DLL could inadvertently enable them.

Example Code

This example shows how DosError and DosErrClass handle errors. Run this program without a diskette in drive A: so that the DosOpen function call fails with a "device not ready" condition, or run it with a disk there for a "file not found" condition.

 #define INCL_DOSFILEMGR   /* File Manager values */
 #define INCL_DOSERRORS    /* DOS error values    */
 #define INCL_DOSMISC      /* DOS miscellaneous   */
 #include <os2.h>
 #include <stdio.h>

 int main(VOID) {
 UCHAR        uchFileName[80] = "A:\\NONEXIST.ZQX"; /* File to fail on      */
 HFILE        hfConfig      = 0;             /* Handle for Config file      */
 ULONG        ulOpenAction  = 0,             /* Action taken by DosOpen     */
              ulErrorClass  = 0,             /* Type of error encountered   */
              ulErrorAction = 0,             /* Action warranted by error   */
              ulErrorLoc    = 0;             /* Where error occurred        */
 APIRET       rc            = NO_ERROR,      /* Return code                 */
              DosOpenRc     = NO_ERROR;      /* Return code from DosOpen    */

  rc = DosError(FERR_DISABLEHARDERR); /* Suppress error window.  If this is
                                         omitted, OS/2 will put up an error
                                         window asking the user to intervene */
  if (rc != NO_ERROR) {
     printf("DosError error: return code = %u\n", rc);
     return 1;

  DosOpenRc = DosOpen(uchFileName,          /* File to open (path and name) */
               &hfConfig,                   /* File handle returned         */
               &ulOpenAction,               /* Action taken by DosOpen      */
               0L,0L,        /* Primary allocation and attributes (ignored) */
               OPEN_ACTION_FAIL_IF_NEW |
               OPEN_ACTION_OPEN_IF_EXISTS,  /* Open an existing file only   */
               OPEN_SHARE_DENYNONE   |
               OPEN_ACCESS_READWRITE,       /* Read and write access        */
               0L);                         /* Extended attributes(ignored) */

    if (DosOpenRc == NO_ERROR) {
        printf("DosOpen successful... but it should have failed.\n");
        return 1;
    } else {
      rc = DosErrClass(DosOpenRc,           /* Return code from failing API */
                       &ulErrorClass,       /* Class of error               */
                       &ulErrorAction,      /* Action to take for error     */
                       &ulErrorLoc);        /* Where did the error occur?   */

      if (rc != NO_ERROR) {
          printf("DosErrClass error: return code = %u\n", rc);
          return 1;
      } else {
          printf("rc= %u  ErrorClass= %u  ErrorLoc= %u\n",
                  DosOpenRc, ulErrorClass, ulErrorLoc);
          printf("ErrorAction= %u means: ", ulErrorAction);
          switch (ulErrorAction) {
           case(ERRACT_RETRY):  printf("Retry immediately");    break;
           case(ERRACT_DLYRET): printf("Retry after a delay");  break;
           case(ERRACT_USER):   printf("Incorrect user input"); break;
           case(ERRACT_ABORT):  printf("Terminate in an orderly fashion");
           case(ERRACT_PANIC):  printf("Terminate NOW");        break;
           case(ERRACT_IGNORE): printf("Ignore this error");    break;
           case(ERRACT_INTRET): printf("Retry after user intervenes");
           default:             printf("Unknown error action"); break;
          } /* switch */
   }  /* DosOpen failure */

  rc = DosError(FERR_ENABLEHARDERR);        /* Re-enable error window */
  if (rc != NO_ERROR) {
     printf("DosError error: return code = %u\n", rc);
     return 1;

  return NO_ERROR;

Related Functions