Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
some test code and bugs fixed + add of some accessors to members of private data...
[simgrid.git] / src / xbt / error.c
1 /* $Id$ */
2
3 /* error - Error handling functions                                         */
4
5 /* Authors: Martin Quinson                                                  */
6 /* Copyright (C) 2001,2002,2003,2004 the OURAGAN project.                   */
7
8 /* This program is free software; you can redistribute it and/or modify it
9    under the terms of the license (GNU LGPL) which comes with this package. */
10
11 #include "xbt/error.h"
12 #include "xbt/sysdep.h"
13
14 /**
15  * \brief Usefull to do nice error repporting messages.
16  *
17  * \param errcode 
18  * \return the printable name of an error code
19  *
20  */
21 const char *xbt_error_name(xbt_error_t errcode)  {
22
23    switch (errcode) {
24       
25     case no_error: return "success";
26     case old_mismatch_error: return "mismatch";
27     case old_system_error: return "system";
28     case old_network_error: return "network";
29     case old_timeout_error: return "timeout";
30     case old_thread_error: return "thread";
31     case old_unknown_error: return "unclassified";
32     default:
33       return "SEVERE ERROR in error repporting module";
34    }
35 }
36
37 XBT_LOG_EXTERNAL_CATEGORY(xbt);
38 XBT_LOG_DEFAULT_CATEGORY(xbt);
39   
40 /**
41  * @brief Kill the program with an error message 
42  * \param msg 
43  *
44  * Things are so messed up that the only thing to do now, is to stop the program.
45  *
46  * The message is handled by a CRITICAL logging request
47  *
48  * If you want to pass arguments to the format, you can always write xbt_assert1(0,"fmt",args)
49  */
50 void xbt_die (const char *msg) {
51    CRITICAL1("%s",msg);
52    xbt_abort();
53 }
54
55 /** @brief Kill the program in silence */
56 void xbt_abort(void) {
57    abort();
58 }