home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v92.tgz / v92.tar / v92 / src / runtime / errmsg.r < prev    next >
Text File  |  1996-03-22  |  3KB  |  158 lines

  1. /*
  2.  * errmsg.r -- err_msg, irunerr, drunerr
  3.  */
  4.  
  5. hidden novalue err_txt Params((int n));
  6.  
  7. #ifdef PresentationManager
  8. extern MRESULT_N_EXPENTRY RuntimeErrorDlgProc(HWND, ULONG, MPARAM, MPARAM);
  9. HAB HInterpAnchorBlock;
  10. #endif                    /* PresentationManager */
  11.  
  12. extern struct errtab errtab[];        /* error numbers and messages */
  13.  
  14. /*
  15.  * err_msg - print run-time error message, performing trace back if required.
  16.  *  This function underlies the rtt runerr() construct.
  17.  */
  18. novalue err_msg(n, v)
  19. int n;
  20. dptr v;
  21. {
  22.    register struct errtab *p;
  23. #ifdef PresentationManager
  24.    HMODULE modhand;
  25. #endif
  26.  
  27.    if (n == 0) {
  28.       k_errornumber = t_errornumber;
  29.       k_errorvalue = t_errorvalue;
  30.       have_errval = t_have_val;
  31.       }
  32.    else {
  33.       k_errornumber = n;
  34.       if (v == NULL) {
  35.          k_errorvalue = nulldesc;
  36.          have_errval = 0;
  37.          }
  38.       else {
  39.          k_errorvalue = *v;
  40.          have_errval = 1;
  41.          }
  42.       }
  43.  
  44.    k_errortext = "";
  45.    for (p = errtab; p->err_no > 0; p++)
  46.       if (p->err_no == k_errornumber) {
  47.          k_errortext = p->errmsg;
  48.          break;
  49.          }
  50.  
  51.    EVVal((word)k_errornumber,E_Error);
  52.  
  53. #ifndef PresentationManager
  54.    if (pfp != NULL) {
  55.       if (IntVal(kywd_err) == 0 || !err_conv) {
  56.          fprintf(stderr, "\nRun-time error %d\n", k_errornumber);
  57. #if COMPILER
  58.          if (line_info)
  59.             fprintf(stderr, "File %s; Line %d\n", file_name, line_num);
  60. #else                    /* COMPILER */
  61.          fprintf(stderr, "File %s; Line %ld\n", findfile(ipc.opnd),
  62.             (long)findline(ipc.opnd));
  63. #endif                    /* COMPILER */
  64.          }
  65.       else {
  66.          IntVal(kywd_err)--;
  67.          return;
  68.          }
  69.       }
  70.    else
  71.       fprintf(stderr, "\nRun-time error %d in startup code\n", n);
  72.    fprintf(stderr, "%s\n", k_errortext);
  73.  
  74.    if (have_errval) {
  75.       fprintf(stderr, "offending value: ");
  76.       outimage(stderr, &k_errorvalue, 0);
  77.       putc('\n', stderr);
  78.       }
  79.  
  80.    if (!debug_info)
  81.       c_exit(ErrorExit);
  82.  
  83.    if (pfp == NULL) {        /* skip if start-up problem */
  84.       if (dodump)
  85.          abort();
  86.       c_exit(ErrorExit);
  87.       }
  88.  
  89.    fprintf(stderr, "Traceback:\n");
  90.    tracebk(pfp, argp);
  91.    fflush(stderr);
  92.  
  93.  
  94.    if (dodump)
  95.       abort();
  96.  
  97.    c_exit(ErrorExit);
  98. #else                    /* PresentationManager */
  99.  
  100.   if (pfp != NULL) {
  101.      if (IntVal(kywd_err) == 0 || !err_conv) {
  102.      DosQueryModuleHandle("xiconxdl.dll",&modhand);
  103.      if (WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, RuntimeErrorDlgProc, modhand,
  104.         IDD_RUNERR, NULL) == DID_ERROR) {
  105.  
  106.       WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
  107.           "An Error occurred, but the dialog cannot be loaded.\nExecution halting.",
  108.           "Icon Runtime System", 0, MB_OK|MB_ICONHAND|MB_MOVEABLE);
  109.      }
  110.      }
  111.      else {
  112.     IntVal(kywd_err)--;
  113.     return;
  114.      }
  115.   }
  116.  
  117.   if (dodump)
  118.     abort();
  119.  
  120.   c_exit(ErrorExit);
  121. #endif                    /* PresentationManager */
  122. }
  123.  
  124. /*
  125.  * irunerr - print an error message when the offending value is a C_integer
  126.  *  rather than a descriptor.
  127.  */
  128. novalue irunerr(n, v)
  129. int n;
  130. C_integer v;
  131.    {
  132.    t_errornumber = n;
  133.    IntVal(t_errorvalue) = v;
  134.    t_errorvalue.dword = D_Integer;
  135.    t_have_val = 1;
  136.    err_msg(0,NULL);
  137.    }
  138.  
  139. /*
  140.  * drunerr - print an error message when the offending value is a C double
  141.  *  rather than a descriptor.
  142.  */
  143. novalue drunerr(n, v)
  144. int n;
  145. double v;
  146.    {
  147.    union block *bp;
  148.  
  149.    bp = (union block *)alcreal(v);
  150.    if (bp != NULL) {
  151.       t_errornumber = n;
  152.       BlkLoc(t_errorvalue) = bp;
  153.       t_errorvalue.dword = D_Real;
  154.       t_have_val = 1;
  155.       }
  156.    err_msg(0,NULL);
  157.    }
  158.