From a037fbedc3671a0d3803b428b607c88ca887bafc Mon Sep 17 00:00:00 2001 From: Robert burner Schadek Date: Thu, 29 Jan 2015 23:17:30 +0100 Subject: [PATCH] uri documentation update * moved some examples to unittests * made a only privately used enum private * URIException made up to spec grammar fix --- std/uri.d | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/std/uri.d b/std/uri.d index ac960b094..ce79f36ca 100644 --- a/std/uri.d +++ b/std/uri.d @@ -38,20 +38,21 @@ private import std.traits : isSomeChar; import core.exception : OutOfMemoryError; import std.exception : assumeUnique; +/** This Exception is thrown if something goes wrong when encoding or +decoding a URI. +*/ class URIException : Exception { - @safe pure nothrow this() + import std.array : empty; + @safe pure nothrow this(string msg, string file = __FILE__, + size_t line = __LINE__, Throwable next = null) { - super("URI Exception"); - } - - @safe pure nothrow this(string msg) - { - super("URI Exception: " ~ msg); + super("URI Exception" ~ (!msg.empty ? ": " ~ msg : ""), file, line, + next); } } -enum +private enum { URI_Alpha = 1, URI_Reserved = 2, @@ -442,6 +443,7 @@ size_t uriLength(Char)(in Char[] s) if (isSomeChar!Char) return i; } +/// unittest { string s1 = "http://www.digitalmars.com/~fred/fredsRX.html#foo end!"; @@ -504,6 +506,7 @@ size_t emailLength(Char)(in Char[] s) if (isSomeChar!Char) return i; } +/// unittest { string s1 = "my.e-mail@www.example-domain.com with garbage added";