is collectException working for every exceptions ?
Ali Çehreli
acehreli at yahoo.com
Tue Mar 19 00:07:44 UTC 2019
On 03/18/2019 11:54 AM, Roman Sztergbaum wrote:
> Hello as the subject say i'm asking this question because with the
> following code
Andre Pany has already explained. Otherwise, I was going to say
"collectException can collect Exceptions, not exceptions." ;)
There have been many discussions on the General forum on when to call
assert() vs. enforce() (essentially, 'throw new Exception') and what
should go inside contracts.
Unrelated, with expression based contracts and the 'body' keyword now
being an optional (context-dependent?) keyword, your function can be
written more cleanly:
private config_create_answer create_config(string[] args)
in (args !is null, "args cannot be null")
in (args.length == 2, "need 1 arguments")
out (r; r.state == "SUCCESS", "create_config should success")
out (r; !r.config_key.empty, "config_key should not be empty")
out (r; !r.readonly_config_key.empty, "readonly_config_key should
not be empty");
{
// ...
}
Ali
More information about the Digitalmars-d-learn
mailing list