is collectException working for every exceptions ?
Roman Sztergbaum
rmscastle at gmail.com
Mon Mar 18 18:54:22 UTC 2019
Hello as the subject say i'm asking this question because with
the following code
```
private config_create_answer create_config(string[] args)
in
{
assert(args !is null, "args cannot be null");
assert(args.length == 2, "need 1 arguments");
}
out (r)
{
assert(r.state == "SUCCESS", "create_config should
success");
assert(!r.config_key.empty, "config_key should not be
empty");
assert(!r.readonly_config_key.empty, "readonly_config_key
should not be empty");
}
body
{
string config_name;
getopt(args, "name", &config_name);
auto cfg = (cast(const
char[])(std.file.read("../API_doc/json_recipes/config_create.json")))
.deserialize!config_create;
cfg.config_name = config_name.strip("\"");
client_.socket.send(cfg.serializeToJson);
auto answer = new ubyte[256];
client_.socket.receive(answer);
client_.socket.getErrorText.writeln;
return (cast(string)
answer).deserialize!config_create_answer;
}
unittest
{
import std.exception : collectException;
auto cli = new CLI("/tmp/raven-os_service_albinos.sock");
assert(cli.create_config(["create_config", "--name=toto"])
.state == "SUCCESS", "should be success");
assert(cli.create_config(["create_config",
"--name=\"titi\""])
.state == "SUCCESS", "should be success");
assert(collectException(cli.create_config(["create_config",
"--name="]))); //here is my problem
}
```
i would like to specify `collectException!GetOptException`, but
it's seem's make the program exit with fail status.
any idea what i'm doing wrong ?
also it's my first d program, so if anything seem's bad let me
know
More information about the Digitalmars-d-learn
mailing list