migrate other Phobos modules to use std.exception.basicExceptionCtors

This commit is contained in:
Shriramana Sharma 2016-01-13 19:39:21 +05:30
parent 8ddd871779
commit 5978ca7831
8 changed files with 58 additions and 154 deletions

View file

@ -299,10 +299,7 @@ class MailboxFull : Exception
*/ */
class TidMissingException : Exception class TidMissingException : Exception
{ {
this(string msg, string file = __FILE__, size_t line = __LINE__) mixin basicExceptionCtors;
{
super(msg, file, line);
}
} }
@ -1695,8 +1692,7 @@ void yield(T)(ref T value)
cur.m_value = &value; cur.m_value = &value;
return Fiber.yield(); return Fiber.yield();
} }
throw new Exception("yield(T) called with no active generator for the supplied type", throw new Exception("yield(T) called with no active generator for the supplied type");
__FILE__, __LINE__);
} }

View file

@ -94,6 +94,7 @@ module std.csv;
import std.conv; import std.conv;
import std.range.primitives; import std.range.primitives;
import std.traits; import std.traits;
import std.exception; // basicExceptionCtors
/** /**
* Exception containing the row and column for when an exception was thrown. * Exception containing the row and column for when an exception was thrown.
@ -111,20 +112,22 @@ class CSVException : Exception
/// ///
size_t row, col; size_t row, col;
// FIXME: Use std.exception.basicExceptionCtors here once bug #11500 is fixed
this(string msg, string file = __FILE__, size_t line = __LINE__, this(string msg, string file = __FILE__, size_t line = __LINE__,
Throwable next = null) @safe pure Throwable next = null) @nogc @safe pure nothrow
{ {
super(msg, file, line, next); super(msg, file, line, next);
} }
this(string msg, Throwable next, string file = __FILE__, this(string msg, Throwable next, string file = __FILE__,
size_t line = __LINE__) @safe pure size_t line = __LINE__) @nogc @safe pure nothrow
{ {
super(msg, file, line, next); super(msg, file, line, next);
} }
this(string msg, size_t row, size_t col, Throwable next = null, this(string msg, size_t row, size_t col, Throwable next = null,
string file = __FILE__, size_t line = __LINE__) @safe pure string file = __FILE__, size_t line = __LINE__) @nogc @safe pure nothrow
{ {
super(msg, next, file, line); super(msg, next, file, line);
this.row = row; this.row = row;
@ -171,17 +174,7 @@ class IncompleteCellException : CSVException
/// already been fed to the output range. /// already been fed to the output range.
dstring partialData; dstring partialData;
this(string msg, string file = __FILE__, size_t line = __LINE__, mixin basicExceptionCtors;
Throwable next = null) @safe pure
{
super(msg, file, line);
}
this(string msg, Throwable next, string file = __FILE__, size_t line =
__LINE__) @safe pure
{
super(msg, next, file, line);
}
} }
@safe pure unittest @safe pure unittest
@ -213,17 +206,7 @@ class IncompleteCellException : CSVException
*/ */
class HeaderMismatchException : CSVException class HeaderMismatchException : CSVException
{ {
this(string msg, string file = __FILE__, size_t line = __LINE__, mixin basicExceptionCtors;
Throwable next = null) @safe pure
{
super(msg, file, line);
}
this(string msg, Throwable next, string file = __FILE__,
size_t line = __LINE__) @safe pure
{
super(msg, next, file, line);
}
} }
@safe pure unittest @safe pure unittest

View file

@ -33,6 +33,7 @@ Distributed under the Boost Software License, Version 1.0.
module std.getopt; module std.getopt;
import std.traits; import std.traits;
import std.exception; // basicExceptionCtors
/** /**
Thrown on one of the following conditions: Thrown on one of the following conditions:
@ -45,18 +46,7 @@ $(UL
*/ */
class GetOptException : Exception class GetOptException : Exception
{ {
@safe pure nothrow mixin basicExceptionCtors;
this(string msg, string file = __FILE__,
size_t line = __LINE__)
{
super(msg, file, line);
}
@safe pure nothrow
this(string msg, Exception next, string file = __FILE__,
size_t line = __LINE__)
{
super(msg, file, line, next);
}
} }
static assert(is(typeof(new GetOptException("message")))); static assert(is(typeof(new GetOptException("message"))));

View file

@ -2186,15 +2186,10 @@ unittest
} }
} }
/// An exception that signals a problem with starting or waiting for a process. /// An exception that signals a problem with starting or waiting for a process.
class ProcessException : Exception class ProcessException : Exception
{ {
// Standard constructor. mixin basicExceptionCtors;
this(string msg, string file = __FILE__, size_t line = __LINE__)
{
super(msg, file, line);
}
// Creates a new ProcessException based on errno. // Creates a new ProcessException based on errno.
static ProcessException newFromErrno(string customMsg = null, static ProcessException newFromErrno(string customMsg = null,

View file

@ -741,9 +741,5 @@ int quickTestFwd(RegEx)(uint pc, dchar front, const ref RegEx re)
///Exception object thrown in case of errors during regex compilation. ///Exception object thrown in case of errors during regex compilation.
public class RegexException : Exception public class RegexException : Exception
{ {
/// mixin basicExceptionCtors;
@trusted this(string msg, string file = __FILE__, size_t line = __LINE__)
{//@@@BUG@@@ Exception constructor is not @safe
super(msg, file, line);
}
} }

View file

@ -50,7 +50,7 @@ import core.stdc.stdint, core.stdc.string, std.string, core.stdc.stdlib, std.con
import core.stdc.config; import core.stdc.config;
import core.time : dur, Duration; import core.time : dur, Duration;
import std.exception : assumeUnique, enforce, collectException; import std.exception;
import std.internal.cstring; import std.internal.cstring;
@ -145,17 +145,7 @@ version(unittest)
/// Base exception thrown by $(D std.socket). /// Base exception thrown by $(D std.socket).
class SocketException: Exception class SocketException: Exception
{ {
/// mixin basicExceptionCtors;
this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null) pure nothrow
{
super(msg, file, line, next);
}
///
this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__) pure nothrow
{
super(msg, next, file, line);
}
} }
@ -279,34 +269,14 @@ class SocketOSException: SocketException
/// Socket exceptions representing invalid parameters specified by user code. /// Socket exceptions representing invalid parameters specified by user code.
class SocketParameterException: SocketException class SocketParameterException: SocketException
{ {
/// mixin basicExceptionCtors;
this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null) pure nothrow
{
super(msg, file, line, next);
}
///
this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__) pure nothrow
{
super(msg, next, file, line);
}
} }
/// Socket exceptions representing attempts to use network capabilities not /// Socket exceptions representing attempts to use network capabilities not
/// available on the current system. /// available on the current system.
class SocketFeatureException: SocketException class SocketFeatureException: SocketException
{ {
/// mixin basicExceptionCtors;
this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null) pure nothrow
{
super(msg, file, line, next);
}
///
this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__) pure nothrow
{
super(msg, next, file, line);
}
} }
@ -625,30 +595,39 @@ unittest
} }
/** private mixin template socketOSExceptionCtors()
* Class for exceptions thrown from an $(D InternetHost).
*/
class HostException: SocketOSException
{ {
/// ///
this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null, int err = _lasterr()) this(string msg, string file = __FILE__, size_t line = __LINE__,
Throwable next = null, int err = _lasterr())
{ {
super(msg, file, line, next, err); super(msg, file, line, next, err);
} }
/// ///
this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__, int err = _lasterr()) this(string msg, Throwable next, string file = __FILE__,
size_t line = __LINE__, int err = _lasterr())
{ {
super(msg, next, file, line, err); super(msg, next, file, line, err);
} }
/// ///
this(string msg, int err, string file = __FILE__, size_t line = __LINE__, Throwable next = null) this(string msg, int err, string file = __FILE__, size_t line = __LINE__,
Throwable next = null)
{ {
super(msg, next, file, line, err); super(msg, next, file, line, err);
} }
} }
/**
* Class for exceptions thrown from an $(D InternetHost).
*/
class HostException: SocketOSException
{
mixin socketOSExceptionCtors;
}
/** /**
* $(D InternetHost) is a class for resolving IPv4 addresses. * $(D InternetHost) is a class for resolving IPv4 addresses.
* *
@ -1251,23 +1230,7 @@ unittest
*/ */
class AddressException: SocketOSException class AddressException: SocketOSException
{ {
/// mixin socketOSExceptionCtors;
this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null, int err = _lasterr())
{
super(msg, file, line, next, err);
}
///
this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__, int err = _lasterr())
{
super(msg, next, file, line, err);
}
///
this(string msg, int err, string file = __FILE__, size_t line = __LINE__, Throwable next = null)
{
super(msg, next, file, line, err);
}
} }
@ -2080,23 +2043,7 @@ static if (is(sockaddr_un))
*/ */
class SocketAcceptException: SocketOSException class SocketAcceptException: SocketOSException
{ {
/// mixin socketOSExceptionCtors;
this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null, int err = _lasterr())
{
super(msg, file, line, next, err);
}
///
this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__, int err = _lasterr())
{
super(msg, next, file, line, err);
}
///
this(string msg, int err, string file = __FILE__, size_t line = __LINE__, Throwable next = null)
{
super(msg, next, file, line, err);
}
} }
/// How a socket is shutdown: /// How a socket is shutdown:

View file

@ -36,20 +36,14 @@ private import core.stdc.stdlib;
private import std.utf; private import std.utf;
private import std.traits : isSomeChar; private import std.traits : isSomeChar;
import core.exception : OutOfMemoryError; import core.exception : OutOfMemoryError;
import std.exception : assumeUnique; import std.exception;
/** This Exception is thrown if something goes wrong when encoding or /** This Exception is thrown if something goes wrong when encoding or
decoding a URI. decoding a URI.
*/ */
class URIException : Exception class URIException : Exception
{ {
import std.array : empty; mixin basicExceptionCtors;
@safe pure nothrow this(string msg, string file = __FILE__,
size_t line = __LINE__, Throwable next = null)
{
super("URI Exception" ~ (!msg.empty ? ": " ~ msg : ""), file, line,
next);
}
} }
private enum private enum

View file

@ -20,10 +20,11 @@
+/ +/
module std.utf; module std.utf;
import std.meta; // AliasSeq import std.meta; // AliasSeq
import std.range.primitives; import std.range.primitives;
import std.traits; // isSomeChar, isSomeString import std.traits; // isSomeChar, isSomeString
import std.typecons : Flag; import std.typecons; // Flag
import std.exception; // basicExceptionCtors
//debug=utf; // uncomment to turn on debugging printf's //debug=utf; // uncomment to turn on debugging printf's
@ -51,14 +52,16 @@ class UTFException : Exception
return this; return this;
} }
@safe pure nothrow // FIXME: Use std.exception.basicExceptionCtors here once bug #11500 is fixed
this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null)
this(string msg, string file = __FILE__, size_t line = __LINE__,
Throwable next = null) @nogc @safe pure nothrow
{ {
super(msg, file, line, next); super(msg, file, line, next);
} }
@safe pure this(string msg, size_t index, string file = __FILE__,
this(string msg, size_t index, string file = __FILE__, size_t line = __LINE__, Throwable next = null) size_t line = __LINE__, Throwable next = null) @safe pure nothrow
{ {
UnsignedStringBuf buf = void; UnsignedStringBuf buf = void;
msg ~= " (at index " ~ unsignedToTempString(index, buf, 10) ~ ")"; msg ~= " (at index " ~ unsignedToTempString(index, buf, 10) ~ ")";
@ -306,7 +309,7 @@ unittest
{ {
import std.conv : to; import std.conv : to;
import std.exception; import std.exception;
import std. string : format; import std.string : format;
import core.exception : AssertError; import core.exception : AssertError;
static void test(string s, dchar c, size_t i = 0, size_t line = __LINE__) static void test(string s, dchar c, size_t i = 0, size_t line = __LINE__)
{ {
@ -414,7 +417,7 @@ unittest
{ {
import std.conv : to; import std.conv : to;
import std.exception; import std.exception;
import std. string : format; import std.string : format;
import core.exception : AssertError; import core.exception : AssertError;
static void test(wstring s, dchar c, size_t i = 0, size_t line = __LINE__) static void test(wstring s, dchar c, size_t i = 0, size_t line = __LINE__)
{ {
@ -493,7 +496,7 @@ unittest
{ {
import std.conv : to; import std.conv : to;
import std.exception; import std.exception;
import std. string : format; import std.string : format;
import core.exception : AssertError; import core.exception : AssertError;
static void test(dstring s, dchar c, size_t i = 0, size_t line = __LINE__) static void test(dstring s, dchar c, size_t i = 0, size_t line = __LINE__)
{ {
@ -639,7 +642,7 @@ unittest
{ {
import std.conv : to; import std.conv : to;
import std.exception; import std.exception;
import std. string : format; import std.string : format;
import core.exception : AssertError; import core.exception : AssertError;
static void test(string s, dchar c, size_t i = size_t.max, size_t line = __LINE__) static void test(string s, dchar c, size_t i = size_t.max, size_t line = __LINE__)
{ {
@ -736,7 +739,7 @@ unittest
{ {
import std.conv : to; import std.conv : to;
import std.exception; import std.exception;
import std. string : format; import std.string : format;
import core.exception : AssertError; import core.exception : AssertError;
static void test(wstring s, dchar c, size_t i = size_t.max, size_t line = __LINE__) static void test(wstring s, dchar c, size_t i = size_t.max, size_t line = __LINE__)
{ {
@ -821,7 +824,7 @@ unittest
{ {
import std.conv : to; import std.conv : to;
import std.exception; import std.exception;
import std. string : format; import std.string : format;
import core.exception : AssertError; import core.exception : AssertError;
static void test(dstring s, dchar c, size_t i = size_t.max, size_t line = __LINE__) static void test(dstring s, dchar c, size_t i = size_t.max, size_t line = __LINE__)
{ {
@ -1579,7 +1582,7 @@ version(unittest) private void testDecode(R)(R range,
size_t line = __LINE__) size_t line = __LINE__)
{ {
import std.exception; import std.exception;
import std. string : format; import std.string : format;
import core.exception : AssertError; import core.exception : AssertError;
static if (hasLength!R) static if (hasLength!R)
@ -1608,7 +1611,7 @@ version(unittest) private void testDecodeFront(R)(ref R range,
size_t line = __LINE__) size_t line = __LINE__)
{ {
import std.exception; import std.exception;
import std. string : format; import std.string : format;
import core.exception : AssertError; import core.exception : AssertError;
static if (hasLength!R) static if (hasLength!R)
@ -1640,7 +1643,7 @@ version(unittest) private void testBothDecode(R)(R range,
version(unittest) private void testBadDecode(R)(R range, size_t index, size_t line = __LINE__) version(unittest) private void testBadDecode(R)(R range, size_t index, size_t line = __LINE__)
{ {
import std.exception; import std.exception;
import std. string : format; import std.string : format;
import core.exception : AssertError; import core.exception : AssertError;
immutable initialIndex = index; immutable initialIndex = index;
@ -2815,7 +2818,7 @@ private P toUTFzImpl(P, S)(S str) @safe pure
{ {
import std.conv : to; import std.conv : to;
import std.exception; import std.exception;
import std. string : format; import std.string : format;
import core.exception : AssertError; import core.exception : AssertError;
import std.algorithm; import std.algorithm;