https://issues.dlang.org/show_bug.cgi?id=17226

Steven Schveighoffer <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #12 from Steven Schveighoffer <[email protected]> ---
What about creating a wrapper for format:

```d
string assertFormat(Args...)(string fmt, Args args)
{
   try {
     return format(fmt, args);
   } catch(Exception ex) {
     return "Error while evaluating assert message: " ~ ex.toString;
   }
}


// use like
assert(i == 42, assertFormat("Something %s", functionThatThrows()));
```

This solves the problem, and also doesn't throw away any information. Plus it's
not unpleasant to use.

Yes, it's opt in. So what? It can just be a best practice recommendation.

--

Reply via email to