X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/16bbb8a8212497d9c44c81333ed2c0e689e0c5af..5f9b13c6302e914a514168da8ff54818c0ee6787:/src/surf/sg_platf.cpp diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index e2968b1da6..62c611547b 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -108,7 +108,7 @@ void sg_platf_new_router(sg_platf_router_cbarg_t router) xbt_dynar_t ctn_str = xbt_str_split_str(router->coord, " "); xbt_dynar_t ctn = xbt_dynar_new(sizeof(double),NULL); xbt_dynar_foreach(ctn_str,cursor, str) { - double val = atof(str); + double val = xbt_str_parse_double(str, "Invalid coordinate: %s"); xbt_dynar_push(ctn,&val); } xbt_dynar_shrink(ctn, 0); @@ -271,8 +271,27 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process) xbt_die("Cannot create process without SIMIX."); sg_host_t host = sg_host_by_name(process->host); - if (!host) - THROWF(arg_error, 0, "Host '%s' unknown", process->host); + if (!host) { + // The requested host does not exist. Do a nice message to the user + char *tmp = bprintf("Cannot create process '%s': host '%s' does not exist\nExisting hosts: '",process->function, process->host); + xbt_strbuff_t msg = xbt_strbuff_new_from(tmp); + free(tmp); + xbt_dynar_t all_hosts = xbt_dynar_sort_strings(sg_hosts_as_dynar()); + simgrid::s4u::Host* host; + unsigned int cursor; + xbt_dynar_foreach(all_hosts,cursor, host) { + xbt_strbuff_append(msg,host->name().c_str()); + xbt_strbuff_append(msg,"', '"); + if (msg->used > 1024) { + msg->data[msg->used-3]='\0'; + msg->used -= 3; + + xbt_strbuff_append(msg," ...(list truncated)......");// That will be shortened by 3 chars when existing the loop + } + } + msg->data[msg->used-3]='\0'; + xbt_die("%s", msg->data); + } xbt_main_func_t parse_code = SIMIX_get_registered_function(process->function); xbt_assert(parse_code, "Function '%s' unknown", process->function);