Please reply to this to vote to collectExceptionMsg in std.unittests

Tomek Sowiński just at ask.me
Tue Feb 8 15:28:12 PST 2011


Andrei Alexandrescu napisał:

> Reply here to vote ONLY for the function collectExceptionMsg in Jonathan 
> M Davis's std.unittests. Vote closes on Tue Feb 15.

I'm in two minds. Since Jonathan has improved collectException the proposed function is just a short-hand for:

auto e = collectException!MyException(expression);
assert (e);
assert (e.msg == "...");

or:

assert (collectException!MyException(expression) == new MyException(msg));

I would use these because of the possibility to test properties other than .msg. Also, there's an ambiguity "ex.msg is null" vs. "didn't throw".

But perhaps msg is important enough to deserve a dedicated wrapper. I'll vote in favour, given that the docs are shrunk to something like:

Convenience function for extracting the exception's message. Equivalent of:
---
auto e = collectException(mayThrow);
string msg = e ? e.msg : null;
---

And put a link to collectException.

-- 
Tomek



More information about the Digitalmars-d mailing list