Skip to content

Commit

Permalink
Merge pull request #2737 from 9il/exc
Browse files Browse the repository at this point in the history
avoid triggering issue 13745 in further improvements to come
  • Loading branch information
DmitryOlshansky committed Nov 22, 2014
2 parents 530eab6 + 591d616 commit 0351278
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions std/exception.d
Expand Up @@ -83,13 +83,9 @@ void assertNotThrown(T : Throwable = Exception, E)
}
catch (T t)
{
import std.array : empty;
import std.format : format;
immutable message = msg.empty ? t.msg : msg;
immutable tail = message.empty ? "." : ": " ~ message;
throw new AssertError(format("assertNotThrown failed: %s was thrown%s",
T.stringof, tail),
file, line, t);
immutable message = msg.length == 0 ? t.msg : msg;
immutable tail = message.length == 0 ? "." : ": " ~ message;
throw new AssertError("assertNotThrown failed: " ~ T.stringof ~ " was thrown" ~ tail, file, line, t);
}
}
///
Expand Down Expand Up @@ -231,10 +227,8 @@ void assertThrown(T : Throwable = Exception, E)
expression();
catch (T)
return;
import std.array : empty;
import std.format : format;
throw new AssertError(format("assertThrown failed: No %s was thrown%s%s",
T.stringof, msg.empty ? "." : ": ", msg),
throw new AssertError("assertThrown failed: No " ~ T.stringof ~ " was thrown"
~ (msg.length == 0 ? "." : ": ") ~ msg,
file, line);
}
///
Expand Down Expand Up @@ -1432,7 +1426,7 @@ class ErrnoException : Exception
{
auto s = core.stdc.string.strerror(errno);
}
super(msg~" ("~s[0..s.strlen].idup~")", file, line);
super(msg ~ " (" ~ s[0..s.strlen].idup ~ ")", file, line);
}
}

Expand Down Expand Up @@ -1500,7 +1494,7 @@ class ErrnoException : Exception
CommonType!(T1, T2) ifThrown(E : Throwable = Exception, T1, T2)(lazy scope T1 expression, lazy scope T2 errorHandler)
{
static assert(!is(typeof(return) == void),
"The error handler's return value("~T2.stringof~") does not have a common type with the expression("~T1.stringof~").");
"The error handler's return value(" ~ T2.stringof ~ ") does not have a common type with the expression(" ~ T1.stringof ~ ").");
try
{
return expression();
Expand All @@ -1516,7 +1510,7 @@ CommonType!(T1, T2) ifThrown(E : Throwable = Exception, T1, T2)(lazy scope T1 ex
CommonType!(T1, T2) ifThrown(E : Throwable, T1, T2)(lazy scope T1 expression, scope T2 delegate(E) errorHandler)
{
static assert(!is(typeof(return) == void),
"The error handler's return value("~T2.stringof~") does not have a common type with the expression("~T1.stringof~").");
"The error handler's return value(" ~ T2.stringof ~ ") does not have a common type with the expression(" ~ T1.stringof ~ ").");
try
{
return expression();
Expand All @@ -1532,7 +1526,7 @@ CommonType!(T1, T2) ifThrown(E : Throwable, T1, T2)(lazy scope T1 expression, sc
CommonType!(T1, T2) ifThrown(T1, T2)(lazy scope T1 expression, scope T2 delegate(Exception) errorHandler)
{
static assert(!is(typeof(return) == void),
"The error handler's return value("~T2.stringof~") does not have a common type with the expression("~T1.stringof~").");
"The error handler's return value(" ~ T2.stringof ~ ") does not have a common type with the expression(" ~ T1.stringof ~ ").");
try
{
return expression();
Expand Down

0 comments on commit 0351278

Please sign in to comment.