Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove the public field msg_host_t->name. Use MSG_host_get_name()
[simgrid.git] / doc / gtut-tour-08-exceptions.doc
index fe1fa8b..b9c7e36 100644 (file)
@@ -44,24 +44,25 @@ information about the host on which they were thrown (#xbt_ex_t) along with
 the thrown point in the source code.
 
 The syntax of XBT exceptions should not sound unfamilliar to most of you.
 the thrown point in the source code.
 
 The syntax of XBT exceptions should not sound unfamilliar to most of you.
-You throw them using the #THROW0...#THROW7 macros. They take 2 extra
-arguments in addition to the format and its self arguments: an error
-category (of type #xbt_errcat_t) and an error "value" (an integer;
-pratically, this is often left to 0 in my own code). So, you may have
-something like the following:
-\verbatim THROW3(system_error, 0, "Cannot connect to %s:%d because of %s", hostname, port, reason);\endverbatim
+You throw them using the #THROW and #THROWF macros. They take 2 arguments:
+an error category (of type #xbt_errcat_t) and an error "value" (an integer;
+pratically, this is often left to 0 in my own code). #THROWF also takes a
+message string as extra argument which is a printf-like format string with
+its own arguments. So, you may have something like the following:
+\verbatim THROWF(system_error, 0, "Cannot connect to %s:%d because of %s", hostname, port, reason);\endverbatim
 
 Then, you simply add a #TRY/#CATCH block around your code:
 \verbatim TRY{ 
   /* your code */ 
 
 Then, you simply add a #TRY/#CATCH block around your code:
 \verbatim TRY{ 
   /* your code */ 
-} CATCH(e) { 
+}
+CATCH(e) {
   /* error handling code */
 } \endverbatim
 
 Another strange thing is that you should actually free the memory allocated
 to the exception with xbt_ex_fres() if you manage to deal with them. There
   /* error handling code */
 } \endverbatim
 
 Another strange thing is that you should actually free the memory allocated
 to the exception with xbt_ex_fres() if you manage to deal with them. There
-is a bit more than this on the picture (#CLEANUP blocks, for example), and
-you should check the section \ref XBT_ex for more details.
+is a bit more than this on the picture (#TRY_CLEANUP blocks, for example), and
+you should check the section \ref XBT_ex for more details.
 
 You should be <b>very carfull</b> when using the exceptions. They work great
 when used correctly, but there is a few golden rules you should never break.
 
 You should be <b>very carfull</b> when using the exceptions. They work great
 when used correctly, but there is a few golden rules you should never break.