TRY {
gras_msg_rpccall(toserver, 60, "convert a2i", &string_to_convert,
&long_result);
- } CATCH(e) {
+ }
+ CATCH(e) {
XBT_INFO
("The server refuses to convert %s. Here is the received exception:",
string_to_convert);
Then, you simply add a #TRY/#CATCH block around your code:
\verbatim TRY{
/* your code */
-} CATCH(e) {
+}
+CATCH(e) {
/* error handling code */
} \endverbatim
TRY {
master = gras_socket_client_from_string(argv[1]);
connected = 1;
- } CATCH(e) {
+ }
+ CATCH(e) {
xbt_ex_free(e);
}
if (!connected) {
xbt_ex_t e;
TRY {
xbt_queue_shift_timed(todo,&chunk,0);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != timeout_error) {
RETHROW;
}
TRY {
varstack = xbt_dict_get(ps->space, name);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != mismatch_error)
RETHROW;
XBT_DEBUG("pop(%s)", name);
TRY {
varstack = xbt_dict_get(ps->space, name);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != mismatch_error)
RETHROW;
TRY {
res = gras_datadesc_by_name(name);
- } CATCH(e) {
+ }
+ CATCH(e) {
res = NULL;
xbt_ex_free(e);
}
(gras_datadesc_type_t) xbt_set_get_by_name(gras_datadesc_set_local,
name);
found = 1;
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != not_found_error)
RETHROW;
xbt_ex_free(e);
res =
(gras_datadesc_type_t) xbt_set_get_by_id(gras_datadesc_set_local,
code);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != not_found_error)
RETHROW;
xbt_ex_free(e);
size =
gras_datadesc_memcpy_rec(state, refs, type, (char *) src,
(char *) dst, 0, type->cycle);
- } TRY_CLEANUP {
+ }
+ TRY_CLEANUP {
xbt_dict_reset(refs);
gras_cbps_reset(state);
}
TRY {
gras_datadesc_send_rec(sock, state, refs, type, (char *) src,
type->cycle);
- } TRY_CLEANUP {
+ }
+ TRY_CLEANUP {
xbt_dict_reset(refs);
gras_cbps_reset(state);
}
TRY {
gras_datadesc_recv_rec(sock, state, refs, type,
r_arch, NULL, 0, (char *) dst, -1, type->cycle);
- } TRY_CLEANUP {
+ }
+ TRY_CLEANUP {
xbt_dict_reset(refs);
gras_cbps_reset(state);
}
msgtype =
(gras_msgtype_t) xbt_set_get_by_name(_gras_msgtype_set, namev);
found = 1;
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != not_found_error) {
xbt_free(namev);
RETHROW;
TRY {
res = gras_msgtype_by_namev(name, 0);
- } CATCH(e) {
+ }
+ CATCH(e) {
res = NULL;
xbt_ex_free(e);
}
TRY {
res = (gras_msgtype_t) xbt_set_get_by_name(_gras_msgtype_set, namev);
found = 1;
- } CATCH(e) {
+ }
+ CATCH(e) {
xbt_ex_free(e);
}
if (!found)
TRY {
msg->type =
(gras_msgtype_t) xbt_set_get_by_name(_gras_msgtype_set, msg_name);
- } CATCH(e) {
+ }
+ CATCH(e) {
/* FIXME: Survive unknown messages */
if (e.category == not_found_error) {
xbt_ex_free(e);
TRY {
setup(plug);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category == mismatch_error) {
/* SG plugin raise mismatch when in RL mode (and vice versa) */
free(plug->name);
case SIMIX_SRC_TIMEOUT:
TRY {
THROWF(timeout_error, 0, "Synchro's wait timeout");
- } CATCH(req->issuer->running_ctx->exception) {
+ }
+ CATCH(req->issuer->running_ctx->exception) {
req->issuer->doexception = 1;
}
break;
case SIMIX_FAILED:
TRY {
THROWF(host_error, 0, "Host failed");
- } CATCH(req->issuer->running_ctx->exception) {
+ }
+ CATCH(req->issuer->running_ctx->exception) {
req->issuer->doexception = 1;
}
break;
TRY {
xbt_dict_get(calls, loc); /* Succeed or throw */
known = 1;
- } CATCH(ex) {
+ }
+ CATCH(ex) {
if(ex.category == not_found_error) {
known = 0;
xbt_ex_free(ex);
TRY {
it = xbt_dynar_search(cb_list,&function);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category == not_found_error) {
xbt_ex_free(e);
xbt_die("Trying to remove a callback that is not here! This should not happen");
TRY {
type = xbt_cfg_get_type(cfg, name);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category == not_found_error) {
xbt_ex_free(e);
THROWF(not_found_error, 0,
TRY {
variable = xbt_dict_get((xbt_dict_t) cfg, name);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != not_found_error)
RETHROW;
TRY {
variable = xbt_dict_get((xbt_dict_t) cfg, name);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category == not_found_error) {
xbt_ex_free(e);
THROWF(not_found_error, 0,
TRY {
xbt_cfg_set_parse(myset, "color:blue");
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != not_found_error)
xbt_test_exception(e);
xbt_ex_free(e);
data = xbt_dict_get(head, data);
THROWF(unknown_error, 0,
"Found something which shouldn't be there (%s)", data);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != not_found_error)
xbt_test_exception(e);
xbt_ex_free(e);
traverse(head);
TRY {
debuged_remove(head, "12346");
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != not_found_error)
xbt_test_exception(e);
xbt_ex_free(e);
TRY {
xbt_multidict_set_ext(mdict, keys, lens, data, free_ctn);
- } TRY_CLEANUP {
+ }
+ TRY_CLEANUP {
xbt_dynar_free(&lens);
}
CATCH_ANONYMOUS {
TRY {
xbt_multidict_remove_ext(mdict, keys, lens);
- } TRY_CLEANUP {
+ }
+ TRY_CLEANUP {
xbt_dynar_free(&lens);
}
CATCH_ANONYMOUS {
TRY {
xbt_dynar_search(dynar, elem);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category == not_found_error) {
xbt_ex_free(e);
return 0;
r2 = 5678;
v2 = 5678;
THROWF(unknown_error, 0, "toto");
- } CATCH(ex) {
+ }
+ CATCH(ex) {
xbt_test_add("variable preservation");
if (r1 != 1234)
xbt_test_fail("r1=%d (!= 1234)", r1);
TRY {
v1 = 5678;
THROWF(1, 2, "blah");
- } TRY_CLEANUP {
+ }
+ TRY_CLEANUP {
if (v1 != 5678)
xbt_test_fail("v1 = %d (!= 5678)", v1);
c = 1;
cp3 = mallocex(SMALLAMOUNT);
strcpy(cp1, "foo");
strcpy(cp2, "bar");
- } TRY_CLEANUP {
+ }
+ TRY_CLEANUP {
if (cp3 != NULL)
free(cp3);
if (cp2 != NULL)
cp3 = mallocex(SMALLAMOUNT);
strcpy(cp1, "foo");
strcpy(cp2, "bar");
- } TRY_CLEANUP { /*04 */
+ }
+ TRY_CLEANUP { /*04 */
printf("cp3=%s", cp3 == NULL /*02 */ ? "" : cp3);
if (cp3 != NULL)
free(cp3);
xbt_set_get_by_name(set, data);
THROWF(unknown_error, 0,
"Found something which shouldn't be there (%s)", data);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != not_found_error)
xbt_test_exception(e);
xbt_ex_free(e);
got_expected = 0;
TRY {
gras_msg_handle(0);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category == timeout_error) {
got_expected = 1;
xbt_ex_free(e);
XBT_DEBUG("%s", platformFile);
TRY {
SD_create_environment(platformFile);
- } CATCH(e) {
+ }
+ CATCH(e) {
xbt_die("Error while loading %s: %s",platformFile,e.msg);
}