Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 24 additions & 0 deletions changelog/std-exception-enforceEx.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
`std.exception.enforceEx` was deprecated in favor of `std.exception.enforce`

With 2.079 $(REF enforce, std,exception) became a complete super set of
$(REF enforceEx, std,exception)

$(H3 Corrective action)

Replace:

---
import std.exception;
alias enf = enforceEx!Exception;
assertNotThrown(enf(true));
assertThrown(enf(false, "blah"));
---

with:

---
import std.exception;
alias enf = enforce!Exception;
assertNotThrown(enf(true));
assertThrown(enf(false, "blah"));
---
14 changes: 6 additions & 8 deletions std/exception.d
Original file line number Diff line number Diff line change
Expand Up @@ -636,25 +636,23 @@ T errnoEnforce(T, string file = __FILE__, size_t line = __LINE__)
return value;
}

// @@@DEPRECATED_2.084@@@
// @@@DEPRECATED_2.089@@@
/++
$(RED Deprecated. Please use $(LREF enforce) instead. This function will be removed 2.084.)
$(RED Deprecated. Please use $(LREF enforce) instead. This function will be removed 2.089.)

If $(D !value) is $(D false), $(D value) is returned. Otherwise,
$(D new E(msg, file, line)) is thrown. Or if $(D E) doesn't take a message
and can be constructed with $(D new E(file, line)), then
$(D new E(file, line)) will be thrown.

This is legacy name, it is recommended to use $(D enforce!E) instead.

Example:
--------------------
auto f = enforceEx!FileMissingException(fopen("data.txt"));
auto line = readln(f);
enforceEx!DataCorruptionException(line.length);
--------------------
+/
//deprecated("Please use enforce instead")
deprecated("Use `enforce`. `enforceEx` will be removed with 2.089.")
template enforceEx(E : Throwable)
if (is(typeof(new E("", string.init, size_t.init))))
{
Expand All @@ -667,7 +665,7 @@ if (is(typeof(new E("", string.init, size_t.init))))
}

/+ Ditto +/
//deprecated("Please use enforce instead")
deprecated("Use `enforce`. `enforceEx` will be removed with 2.089.")
template enforceEx(E : Throwable)
if (is(typeof(new E(string.init, size_t.init))) && !is(typeof(new E("", string.init, size_t.init))))
{
Expand All @@ -679,7 +677,7 @@ if (is(typeof(new E(string.init, size_t.init))) && !is(typeof(new E("", string.i
}
}

//deprecated
deprecated
@system unittest
{
import core.exception : OutOfMemoryError;
Expand Down Expand Up @@ -723,7 +721,7 @@ if (is(typeof(new E(string.init, size_t.init))) && !is(typeof(new E("", string.i
static assert(!is(typeof(enforceEx!int(true))));
}

//deprecated
deprecated
@safe unittest
{
alias enf = enforceEx!Exception;
Expand Down