Chapter 9. Error Handling

Error handling is a loosely formalized field of software engineering concerned with treating error situations that are possible and expected but prevent the normal functioning of a system. Exception handling is the current common approach to error handling in many of today’s languages (D included) and has spawned a large lore of guidelines, techniques, and even controversy.

Exceptions are a language feature dedicated to error handling via out-of-band, dedicated control paths. A function unable to return a meaningful result to its caller may throw an exception object that encodes the cause of the error. Throwing is a “get out of jail” card that relieves the function of its normal duties. The exception skips all callers ...

Get The D Programming Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.