Logo AND Algorithmique Numérique Distribuée

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