/[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 930 by johnpye, Sat Oct 28 03:55:19 2006 UTC revision 931 by johnpye, Thu Nov 23 04:31:19 2006 UTC
# Line 83  Line 83 
83  typedef enum error_severity_enum{  typedef enum error_severity_enum{
84      ASC_USER_SUCCESS=0      ASC_USER_SUCCESS=0
85     ,ASC_USER_NOTE=1    /**< a note to the user */     ,ASC_USER_NOTE=1    /**< a note to the user */
86     ,ASC_USER_WARNING   /**< the user has done something bad but tolerable */     ,ASC_USER_WARNING=2 /**< the user has done something bad but tolerable */
87     ,ASC_USER_ERROR     /**< the user has done something wrong */     ,ASC_USER_ERROR=4   /**< the user has done something wrong */
88     ,ASC_PROG_NOTE      /**< a note for the programmer */     ,ASC_PROG_NOTE=8    /**< a note for the programmer */
89     ,ASC_PROG_WARNING   /**< the program encounters an unexpected state */     ,ASC_PROG_WARNING=16/**< the program encounters an unexpected state */
90     ,ASC_PROG_ERROR     /**< the program has failed but can ignore and continue (maybe) */     ,ASC_PROG_ERROR=32  /**< the program has failed but can ignore and continue (maybe) */
91     ,ASC_PROG_FATAL     /**< fatal error, program will exit */     ,ASC_PROG_FATAL=64  /**< fatal error, program will exit */
92  } error_severity_t;  } error_severity_t;
93    
94    #define ASC_ERR_ERR (ASC_PROG_ERROR | ASC_USER_ERROR | ASC_PROG_FATAL)
95    
96  /**  /**
97      Variadic macros to allow nice succint logging and error reporting      Variadic macros to allow nice succint logging and error reporting
# Line 163  typedef struct{ Line 164  typedef struct{
164  } error_reporter_meta_t;  } error_reporter_meta_t;
165    
166  /**  /**
167        This structure provides a means for caching errors so that they can be
168        reported back later in the manner of 'stack traces'. Should be useful
169        for more detailed reporting from parser, external calls, etc.
170    
171        Usage will be
172    
173            int res = 0;
174            error_reporter_tree_start();
175            do_subordinate_tasks();
176            error_reporter_tree_end();
177            if(error_reporter_tree_has_error()){
178                error_reporter_here(ASC_PROG_ERR,"Some errors occurred");
179            }else{
180                error_reporter_tree_clear();
181            }
182    
183        The next 'error_reporter' call after an outermost 'error_reporter_tree_end'
184        will cause the error tree to be output to the error reporting channel.
185    
186        If an 'error_reporter' is found *inside* an an 'error_reporter_tree_start'
187        and 'error_reporter_tree_end', the error message is kept and not output.
188    
189        If the latest set of errors (those found inside the last start..end) are not
190        important, they can be discarded using error_reporter_tree_clear. This will
191        not clear the entire error tree, as there may be errors higher-up that we
192        don't want to discard.
193    
194        After a call to error_reporter_tree_clear(), further errors can still be
195        added within the current TREECURRENT context.
196    */
197    typedef struct ErrorReporterTree{
198        error_reporter_meta_t *err;
199        struct ErrorReporterTree *head; /**< first on the list of child errors */
200        struct ErrorReporterTree *tail; /**< last on the list of child errors */
201        struct ErrorReporterTree *next; /**< next error in the present list */
202        struct ErrorReporterTree *parent; /**< parent error (or NULL) */
203    } error_reporter_tree_t;
204    
205    ASC_DLLSPEC(int) error_reporter_tree_start();
206    ASC_DLLSPEC(int) error_reporter_tree_end();
207    ASC_DLLSPEC(void) error_reporter_tree_clear();
208    ASC_DLLSPEC(int) error_reporter_tree_has_error();
209    
210    /**
211      This is the drop-in replacement for Asc_FPrintf. Anythin you attempt      This is the drop-in replacement for Asc_FPrintf. Anythin you attempt
212      to print to stderr will be captured and passed to the error_reporter_callback      to print to stderr will be captured and passed to the error_reporter_callback
213      function for handling.      function for handling.

Legend:
Removed from v.930  
changed lines
  Added in v.931

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