Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics: handle exception inside exception handler.
[simgrid.git] / examples / gras / rpc / rpc.c
index 9086454..f686f20 100644 (file)
@@ -42,17 +42,17 @@ static void exception_catching(void)
     }
     CATCH(e) {
       gotit = 1;
+      xbt_assert(e.category == unknown_error,
+                 "Got wrong category: %d (instead of %d)", e.category,
+                 unknown_error);
+      xbt_assert(e.value == 42, "Got wrong value: %d (!=42)", e.value);
+      xbt_assert(!strncmp(e.msg, exception_msg, strlen(exception_msg)),
+                 "Got wrong message: %s", e.msg);
+      xbt_ex_free(e);
     }
     if (!gotit) {
       THROWF(unknown_error, 0, "Didn't got the remote exception!");
     }
-    xbt_assert(e.category == unknown_error,
-                "Got wrong category: %d (instead of %d)", e.category,
-                unknown_error);
-    xbt_assert(e.value == 42, "Got wrong value: %d (!=42)", e.value);
-    xbt_assert(!strncmp(e.msg, exception_msg, strlen(exception_msg)),
-                "Got wrong message: %s", e.msg);
-    xbt_ex_free(e);
   }
 }
 
@@ -181,19 +181,19 @@ int client(int argc, char *argv[])
     }
     CATCH(e) {
       gotit = 1;
+      xbt_assert(e.value == 42, "Got wrong value: %d (!=42)", e.value);
+      xbt_assert(!strncmp(e.msg, exception_msg, strlen(exception_msg)),
+                 "Got wrong message: %s", e.msg);
+      xbt_assert(e.category == unknown_error,
+                 "Got wrong category: %d (instead of %d)",
+                 e.category, unknown_error);
+      XBT_INFO
+        ("Got the expected exception when calling the exception raising RPC");
+      xbt_ex_free(e);
     }
     if (!gotit) {
       THROWF(unknown_error, 0, "Didn't got the remote exception!");
     }
-    xbt_assert(e.value == 42, "Got wrong value: %d (!=42)", e.value);
-    xbt_assert(!strncmp(e.msg, exception_msg, strlen(exception_msg)),
-                "Got wrong message: %s", e.msg);
-    xbt_assert(e.category == unknown_error,
-                "Got wrong category: %d (instead of %d)",
-                e.category, unknown_error);
-    XBT_INFO
-        ("Got the expected exception when calling the exception raising RPC");
-    xbt_ex_free(e);
     exception_catching();
   }