Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor English improvements + query #333

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions basics/exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ and should __never__ be caught.

### Catching Exceptions

A common case for exceptions is to validate potentially invalid user input.
A common use case for exceptions is to validate potentially invalid user input.
Once an exception is thrown, the stack will be unwound until the first matching exception
handler is found.

Expand All @@ -20,7 +20,7 @@ catch (FileException e)
}
```

It's possible to have multiple `catch` blocks and a `finally` block that is executed
It's possible to have multiple `catch` blocks. And a `finally` block can be used to ensure that some code is executed
regardless of whether an error occurred. Exceptions are thrown with `throw`.

```d
Expand All @@ -42,12 +42,12 @@ finally
}
```

Remember that the [scope guard](gems/scope-guards) is usually a better solution to the `try-finally`
Note that using [scope guard](gems/scope-guards) is normally a better alternative to the `try-finally`
pattern.

### Custom exceptions

One can easily inherit from `Exception` and create custom exceptions:
Custom exceptions are created by inheriting from the `Exception` class:

```d
class UserNotFoundException : Exception
Expand All @@ -56,7 +56,7 @@ class UserNotFoundException : Exception
super(msg, file, line);
}
}
throw new UserNotFoundException("D-Man is on vacation");
throw new UserNotFoundException("D-User is on vacation");
```

### Enter a safe world with `nothrow`
Expand All @@ -73,7 +73,7 @@ bool lessThan(int a, int b) nothrow
}
```

Please note that the compiler is able to infer attributes for templated code
The compiler is able to infer attributes for templated code
automatically.

### std.exception
Expand Down