From d10ae2ae67cb481dd3213d08e64b8e46ae24dc1b Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Fri, 16 Mar 2018 05:25:56 +0100 Subject: [PATCH] Push deprecation of std.exception.enforceEx --- changelog/std-exception-enforceEx.dd | 24 ++++++++++++++++++++++++ std/exception.d | 14 ++++++-------- 2 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 changelog/std-exception-enforceEx.dd diff --git a/changelog/std-exception-enforceEx.dd b/changelog/std-exception-enforceEx.dd new file mode 100644 index 00000000000..12e42ee5dca --- /dev/null +++ b/changelog/std-exception-enforceEx.dd @@ -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")); +--- diff --git a/std/exception.d b/std/exception.d index 3fddbc50b18..bfbb77de605 100644 --- a/std/exception.d +++ b/std/exception.d @@ -636,17 +636,15 @@ 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")); @@ -654,7 +652,7 @@ T errnoEnforce(T, string file = __FILE__, size_t line = __LINE__) 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)))) { @@ -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)))) { @@ -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; @@ -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;