Search⌘ K
AI Features

Kinds of Errors

Explore the various kinds of errors in D programming including user errors, programmer mistakes, and unexpected situations. Understand when to use exception handling, assertions, and how to manage exceptions effectively to maintain program reliability.

Kinds of errors #

We have seen how useful the exception mechanism is. It enables both the lower and higher-level operations to be aborted right away instead of letting the program continue with incorrect or missing data or behave in any other incorrect way. This does not mean that every error condition warrants throwing an exception. There may be better things to do depending on the kinds of errors.

User errors #

Some errors are caused by the user. As we have seen above, the user may have entered a string like “hello” even though the program has been expecting a number. It may be more appropriate to display an error message and ask the user to enter appropriate data again.
Even so, it may be fine to accept and use the data directly without validating the data upfront; ...