The solution to "Error handling"...
Walter Bright
newshound2 at digitalmars.com
Thu Jul 9 23:26:03 UTC 2026
On 7/9/2026 12:32 AM, Robert Collins wrote:
> Instead of
> only catching exceptions, we started testing common failure scenarios such as
> invalid input, missing resources, API timeouts, and permission issues. We also
> separated user-friendly messages from detailed logs, so users received clear
> guidance while developers still had enough information to troubleshoot the root
> cause.
One testing technique that works well is to have input objects, processing code,
and output objects. One creates "mock" input objects, which can be used to
generate specific bad input. Then write "mock" output objects that, instead of
reporting the error, compare the error against what the expected error would be.
You can see this in action in the lexer unittests in the dmd compiler.
More information about the Digitalmars-d
mailing list