home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / desklib / !DeskLib / h / Error < prev    next >
Encoding:
Text File  |  1993-07-12  |  4.0 KB  |  107 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Error.h
  12.     Author:  Copyright © 1992 Jason Williams
  13.              Improved by Philip Colmer
  14.     Version: 1.054(13 Jul 1993)
  15.     Purpose: Centralised error reporting, with hopefully useful routines,
  16.              but which YOU (the user) can change if you want something
  17.              different
  18.     Mods:    7 Apr 1992 - JCW - Added Error_OutOfMemory
  19.             14 Jun 1993 - PJC - Allowed Error_Report(Fatal) to take
  20.                                 variable arguments
  21.             13 Jul 1993 - PJC - Added varargs to "Internal" versions of above
  22. */
  23.  
  24. #ifndef __dl_error_h
  25. #define __dl_error_h
  26.  
  27. #ifndef __kernel_h
  28. #include "kernel.h"
  29. #endif
  30.  
  31. #ifndef __dl_core_h
  32. #include "Core.h"
  33. #endif
  34.  
  35.  
  36.  
  37. /* Error_ReportInternal ----------------------------------------------------
  38.  * This is identical to Error_Report, except it is used for most DeskLib
  39.  * library internal errors. User code should use Error_Report. This allows
  40.  * you to modify the treatment of internal errors, without affecting your
  41.  * own error handling.
  42.  */
  43. extern void Error_ReportInternal(int errornum, char *report, ...);
  44.  
  45.  
  46. /* Error_ReportFatalInternal -----------------------------------------------
  47.  * This does an Error_ReportInternal, and then calls exit()
  48.  */
  49. extern void Error_ReportFatalInternal(int errornum, char *report, ...);
  50.  
  51.  
  52. /* Error_Report ------------------------------------------------------------
  53.  * This is a centralised user-error reporting function.
  54.  * Call it, citing any error number you want, and any error string you want.
  55.  * The current implementation merely invokes Wimp_ReportError, but use it
  56.  * from your code, as then the method by which you report errors can be
  57.  * altered just by changing Error.c
  58.  *
  59.  * The report is a 'printf' style formatting string, optionally followed
  60.  * by arguments just as in printf commands. This saves you from having to
  61.  * pre-assemble strings to pass in.
  62.  * examples:
  63.  *   Error_Report(5, "My VIDC just blew up!");
  64.  *   Error_Report(6, "You can't put the number %d in there!", thenumber);
  65.  */
  66. extern void Error_Report(int errornum, char *report, ...);
  67.  
  68.  
  69. /* Error_ReportFatal -------------------------------------------------------
  70.  * Exactly the same as Error_Report, except after reporting the error, it
  71.  * terminates the program by calling exit()
  72.  *
  73.  * Takes variable arguments a la 'printf'. See Error_Report for more info.
  74.  */
  75. extern void Error_ReportFatal(int errornum, char *report, ...);
  76.  
  77.  
  78. /* Error_Check -------------------------------------------------------------
  79.  * Used to encapsulate an OS call to automatically check for error return.
  80.  * If the OS call returns an error, then it will be reported, and the
  81.  * function returns TRUE.
  82.  * Otherwise, no action is taken, and FALSE is returned
  83.  */
  84. extern BOOL Error_Check(os_error *error);
  85.  
  86.  
  87. /* Error_CheckFatal --------------------------------------------------------
  88.  * Identical to Error_Check, but calls exit() if an error ocurred
  89.  */
  90. extern void Error_CheckFatal(os_error *error);
  91.  
  92.  
  93. /* Error_OutOfMemory -------------------------------------------------------
  94.  * Reports a memory error (e.g. "Unable to claim enough memory for
  95.  * [Messages]"), where you supply just the "place" of the failure
  96.  * (e.g. in this case, in the "Messages" section)
  97.  * if "fatal" is TRUE, Error_ReportFatal is used, else Error_Report is used.
  98.  *
  99.  * This function ALWAYS returns FALSE (== 0 == NULL), so you can use:
  100.  *   if (spritearea == NULL)
  101.  *     return(Error_OutOfMemory(FALSE, "icon sprites"));
  102.  */
  103. extern BOOL Error_OutOfMemory(BOOL fatal, char *place);
  104.  
  105.  
  106. #endif
  107.