ViewVC logotype

Diff of /branches/relerrorlist/ascend/utilities/error.h

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

revision 3196 by jpye, Sat Apr 22 13:10:46 2017 UTC revision 3197 by jpye, Sun Apr 23 03:30:25 2017 UTC
# Line 160  typedef struct{ Line 160  typedef struct{
160  } error_reporter_meta_t;  } error_reporter_meta_t;
162  /**  /**
163      This structure provides a means for caching errors so that they can be      This structure provides a means for observing when errors were reported in
164      reported back later in the manner of 'stack traces'. Should be useful      nested code, so that we can be sure that high-level routines can report
165      for more detailed reporting from parser, external calls, etc.      error status correctly. This is a bit of a hack because ASCEND doesn't
166        always report errors through return values in a straightforward way.
167      FIXME Also, the structure allows us to watch for cases where errors were reported      
168      at any point between start and end points. We can cache and then suppress or      This structure also provides the ability to suppress error_reporter output
169      output errors, or we can simply watch and note them if they have happened.      (but not CONSOLE_DEBUG though -- at this stage), which can be useful when
170        running batch tasks etc. Potentially (with extra coding) allows just the
171        first few of a long series of errors to be reported.
173      Usage will be      Usage will be
175          bool has_error = 0;          bool has_error = 0;
176          error_reporter_tree_start();          bool is_caching = 0;
177            error_reporter_tree_t *tree = error_reporter_tree_start(is_caching);
178          do_subordinate_tasks();          do_subordinate_tasks();
179          if(error_reporter_tree_has_error()){          has_error = error_reporter_tree_has_error(tree);
             has_error = 1;  
             has_error = 0  
180          if(has_error){          if(has_error){
181              ERROR_REPORTER_NOLINE(ASC_USER_ERROR,"failed");              error_reporter_tree_end(tree);
182                ERROR_REPORTER_NOLINE(ASC_USER_ERROR,"task failed");
183          }else{          }else{
184              ERROR_REPORTER_NOLINE(ASC_USER_SUCCESS,"success");              error_reporter_tree_end_clear(tree);
185                ERROR_REPORTER_NOLINE(ASC_USER_SUCCESS,"task succeeded");
186          }          }
188      The next 'error_reporter' call after an outermost 'error_reporter_tree_end'      The error_reporter_tree_end() call will output any nested errors in the case
189      will cause the error tree to be output to the error reporting channel.      where it is a caching tree without any caching parent(s). If there are
190        parents, the errors will be kept for high-up scrutiny. If there are no
191      If an 'error_reporter' is found *inside* an an 'error_reporter_tree_start'      parents, the errors will the cleared away once they are output.
192      and 'error_reporter_tree_end', the error message is kept and not output.  
193        The error_reporter_tree_end_clear() call will NOT output any nested errors
194      FIXME we need to allow errors to be output even inside a tree, if desired.      and will clear away any nested errors making them invisible to higher-up
195      This choice should be a parameter of error_reporter_tree_start().      nodes in the error tree. This allow errors which have occurred, eg in
196        failed attempts to solve equations, to be suppressed in the case that
197      If the latest set of errors (those found inside the last start..end) are not      alternative actions are taken (eg re-solving with different parameters).
198      important, they can be discarded using error_reporter_tree_clear. This will  
199      not clear the entire error tree, as there may be errors higher-up that we      Both of these commands, error_reporter_tree_end() and
200      don't want to discard.      error_reporter_tree_end_clear() close the current error tree and move the
201        current-tree-pointer up to the parent level if it exists.
202      After a call to error_reporter_tree_clear(), further errors can still be  
203      added within the current TREECURRENT context.      If an 'error_reporter' call is found *inside* an an 'error_reporter_tree_start'
204        and 'error_reporter_tree_end', the error message is recorded in the
205        error_reporter_tree_t.
206  */  */
207  typedef struct ErrorReporterTree{  typedef struct ErrorReporterTree{
208      error_reporter_meta_t *err;      error_reporter_meta_t *err;
# Line 208  typedef struct ErrorReporterTree{ Line 210  typedef struct ErrorReporterTree{
210      struct ErrorReporterTree *head; /**< first on the list of child errors */      struct ErrorReporterTree *head; /**< first on the list of child errors */
211      struct ErrorReporterTree *tail; /**< last on the list of child errors */      struct ErrorReporterTree *tail; /**< last on the list of child errors */
212      struct ErrorReporterTree *next; /**< next error in the present list */      struct ErrorReporterTree *next; /**< next error in the present list */
213        struct ErrorReporterTree *prev; /**< prev error in the present list */
214      struct ErrorReporterTree *parent; /**< parent error (or NULL) */      struct ErrorReporterTree *parent; /**< parent error (or NULL) */
215  } error_reporter_tree_t;  } error_reporter_tree_t;
217  ASC_DLLSPEC int error_reporter_tree_start(int iscaching);  ASC_DLLSPEC error_reporter_tree_t *error_reporter_tree_start(int iscaching);
218  ASC_DLLSPEC int error_reporter_tree_end();  ASC_DLLSPEC int error_reporter_tree_end(error_reporter_tree_t *tree);
219  ASC_DLLSPEC void error_reporter_tree_clear();  ASC_DLLSPEC void error_reporter_tree_end_clear(error_reporter_tree_t *tree);
220  ASC_DLLSPEC int error_reporter_tree_has_error();  ASC_DLLSPEC int error_reporter_tree_has_error(error_reporter_tree_t *tree);
221  ASC_DLLSPEC error_reporter_tree_t *error_reporter_get_tree_current() __attribute__((deprecated("for debugging only!")));  ASC_DLLSPEC ASC_DEPREC error_reporter_tree_t *error_reporter_get_tree_current();
223  /**  /**
224      This is the drop-in replacement for Asc_FPrintf. Anythin you attempt      This is the drop-in replacement for Asc_FPrintf. Anythin you attempt

Removed from v.3196  
changed lines
  Added in v.3197

ViewVC Help
Powered by ViewVC 1.1.22