/[ascend]/trunk/base/generic/utilities/error.h
ViewVC logotype

Diff of /trunk/base/generic/utilities/error.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 413 by johnpye, Fri Mar 31 08:52:57 2006 UTC revision 414 by johnpye, Mon Apr 3 04:55:35 2006 UTC
# Line 74  Line 74 
74  #  define ERR_NORM ""  #  define ERR_NORM ""
75  #  define ERR_BOLD ""  #  define ERR_BOLD ""
76  #endif  #endif
77    
78    /**
79        Error severity codes. This will be used to visually
80        the seriousness of errors. ASC_PROG_ERRORs for example
81        might be red, or be highlighted with a (!) icon, etc.
82    */
83    typedef enum error_severity_enum{
84        ASC_USER_SUCCESS=0
85       ,ASC_USER_NOTE=1    /**< a note to the user */
86       ,ASC_USER_WARNING   /**< the user has done something bad but tolerable */
87       ,ASC_USER_ERROR     /**< the user has done something wrong */
88       ,ASC_PROG_NOTE      /**< a note for the programmer */
89       ,ASC_PROG_WARNING   /**< the program encounters an unexpected state */
90       ,ASC_PROG_ERROR     /**< the program has failed but can ignore and continue (maybe) */
91       ,ASC_PROG_FATAL     /**< fatal error, program will exit */
92    } error_severity_t;
93    
94    
95  /**  /**
96      Variadic macros to allow nice succint logging and error reporting      Variadic macros to allow nice succint logging and error reporting
97      calls from C dialects that support them (GCC, C99 and others)      calls from C dialects that support them (GCC, C99 and others)
# Line 89  Line 107 
107                                   fprintf(stderr, ##args) + \                                   fprintf(stderr, ##args) + \
108                                   fprintf(stderr, ERR_NORM "\n"))                                   fprintf(stderr, ERR_NORM "\n"))
109    
110    # define ERROR_REPORTER_START_HERE(SEV) error_reporter_start(SEV,__FILE__,__LINE__,__func__);
111    
112  #elif defined(HAVE_C99)  #elif defined(HAVE_C99)
113  # define ERROR_REPORTER_DEBUG(...) error_reporter(ASC_PROG_NOTE,__FILE__,__LINE__,__func__,## __VA_ARGS__)  # define ERROR_REPORTER_DEBUG(...) error_reporter(ASC_PROG_NOTE,__FILE__,__LINE__,__func__,## __VA_ARGS__)
114  # define ERROR_REPORTER_HERE(SEV,...) error_reporter(SEV,__FILE__,__LINE__,__func__, ## __VA_ARGS__)  # define ERROR_REPORTER_HERE(SEV,...) error_reporter(SEV,__FILE__,__LINE__,__func__, ## __VA_ARGS__)
# Line 97  Line 117 
117                               fprintf(stderr, ##__VA_ARGS__) + \                               fprintf(stderr, ##__VA_ARGS__) + \
118                               fprintf(stderr, ERR_NORM "\n"))                               fprintf(stderr, ERR_NORM "\n"))
119    
120    #define ERROR_REPORTER_START_HERE(SEV) error_reporter_start(SEV,__FILE__,__LINE__,__func__);
121    
122  #else  #else
123  # define ERROR_REPORTER_DEBUG error_reporter_note_no_line  # define ERROR_REPORTER_DEBUG error_reporter_note_no_line
124  # define ERROR_REPORTER_HERE error_reporter_here  # define ERROR_REPORTER_HERE error_reporter_here
125  # define ERROR_REPORTER_NOLINE error_reporter_noline  # define ERROR_REPORTER_NOLINE error_reporter_noline
126  # define CONSOLE_DEBUG console_debug  # define CONSOLE_DEBUG console_debug
127    # define ERROR_REPORTER_START_HERE(SEV) error_reporter_start(SEV,__FILE__,__LINE__,__FUNCTION__);
128  int error_reporter_note_no_line(const char *fmt,...);  int error_reporter_note_no_line(const char *fmt,...);
129  int error_reporter_here(const error_severity_t sev, const char *fmt,...);  int error_reporter_here(const error_severity_t sev, const char *fmt,...);
130  int error_reporter_noline(const error_severity_t sev, const char *fmt,...);  int error_reporter_noline(const error_severity_t sev, const char *fmt,...);
# Line 109  int console_debug(const char *fmt,...); Line 132  int console_debug(const char *fmt,...);
132  #endif  #endif
133    
134  #define ERROR_REPORTER_START_NOLINE(SEV) error_reporter_start(SEV,NULL,0,NULL);  #define ERROR_REPORTER_START_NOLINE(SEV) error_reporter_start(SEV,NULL,0,NULL);
 #define ERROR_REPORTER_START_HERE(SEV) error_reporter_start(SEV,__FILE__,__LINE__,__func__);  
135    
136  #define ERROR_REPORTER_STAT(sev,stat,msg) \  #define ERROR_REPORTER_STAT(sev,stat,msg) \
137      error_reporter(sev,Asc_ModuleFileName(stat->mod),stat->linenum,NULL,msg)      error_reporter(sev,Asc_ModuleFileName(stat->mod),stat->linenum,NULL,msg)
138    
 /**  
     Error severity codes. This will be used to visually  
     the seriousness of errors. ASC_PROG_ERRORs for example  
     might be red, or be highlighted with a (!) icon, etc.  
 */  
 typedef enum error_severity_enum{  
     ASC_USER_SUCCESS=0  
    ,ASC_USER_NOTE=1    /**< a note to the user */  
    ,ASC_USER_WARNING   /**< the user has done something bad but tolerable */  
    ,ASC_USER_ERROR     /**< the user has done something wrong */  
    ,ASC_PROG_NOTE      /**< a note for the programmer */  
    ,ASC_PROG_WARNING   /**< the program encounters an unexpected state */  
    ,ASC_PROG_ERROR     /**< the program has failed but can ignore and continue (maybe) */  
    ,ASC_PROG_FATAL     /**< fatal error, program will exit */  
 } error_severity_t;  
   
139  /** An alias for ASC_PROG_ERROR */  /** An alias for ASC_PROG_ERROR */
140  #define ASC_PROG_ERR ASC_PROG_ERROR  #define ASC_PROG_ERR ASC_PROG_ERROR
141    
# Line 218  typedef int (*ErrorReporter_fptr_t)( Line 224  typedef int (*ErrorReporter_fptr_t)(
224      If we're using a 'imported error reporter' then this means that we're in      If we're using a 'imported error reporter' then this means that we're in
225      a different DLL to the main ASCEND code. In that case, we will have a      a different DLL to the main ASCEND code. In that case, we will have a
226      pointer to our error reporter function, which will be back in the main      pointer to our error reporter function, which will be back in the main
227      DLL in fact. We need this header file to refer to that global-variable      DLL in fact. We need this header file to refer to that global-variable
228      function pointer instead of assuming that the function is here locally.      function pointer instead of assuming that the function is here locally.
229  */  */
230  static ErrorReporter_fptr_t g_ErrorReporter_fptr;  static ErrorReporter_fptr_t g_ErrorReporter_fptr;

Legend:
Removed from v.413  
changed lines
  Added in v.414

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22