home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a063 / 6.img / SAMPLE / APTFORMS / ERRHNDLR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-24  |  1022 b   |  50 lines

  1. #include <sybfront.h>
  2. #include <sybdb.h>
  3. #include <syberror.h>
  4. #include <sybfrs.h>
  5.  
  6. #if MSDOS
  7. #    include    "aforms.h"
  8. #endif /* MSDOS */
  9.  
  10. /*
  11. **  ERR_HANDLER
  12. **  Catch DB-LIBRARY error messages.
  13. */
  14. int err_handler(dbproc, severity, dberr, oserr, dberrstr, oserrstr)
  15.  
  16. DBPROCESS       *dbproc;
  17. int             severity;
  18. int             dberr;
  19. int             oserr;
  20. char            *dberrstr;
  21. char            *oserrstr;
  22. {
  23.     char msgbuf[100];
  24.  
  25.     /* The message handler has already handled any SQL Server messages. */
  26.     if (dberr == SYBESMSG)
  27.     {
  28.         return(INT_CANCEL);
  29.     }
  30.  
  31.     /* Eliminate warning messages on precision loss. */
  32.     if (dberr == SYBECLPR)
  33.     {
  34.         return(INT_CANCEL);
  35.     }
  36.         
  37.     /* Otherwise, print the DB-LIBRARY error. */
  38.     sprintf(msgbuf, "DB-LIBRARY error:\n\t%s\n", dberrstr);
  39.     fsmessage(msgbuf);
  40.  
  41.     /* Print any operating system errors. */
  42.     if (oserr != DBNOERR)
  43.     {
  44.         sprintf(msgbuf, "Operating system error:\n\t%s\n", oserrstr);
  45.         fsmessage(msgbuf);
  46.     }
  47.  
  48.     return(INT_CANCEL);
  49. }
  50.