Adding exception message for paths not starting with / #251
This commit is contained in:
parent
d25c25c4b2
commit
d4d04d2c96
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
|
using Microsoft.AspNet.Http.Abstractions;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Http
|
namespace Microsoft.AspNet.Http
|
||||||
{
|
{
|
||||||
|
|
@ -29,7 +30,7 @@ namespace Microsoft.AspNet.Http
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(value) && value[0] != '/')
|
if (!string.IsNullOrEmpty(value) && value[0] != '/')
|
||||||
{
|
{
|
||||||
throw new ArgumentException(""/*Resources.Exception_PathMustStartWithSlash*/, nameof(value));
|
throw new ArgumentException(Resources.FormatException_PathMustStartWithSlash(nameof(value)), nameof(value));
|
||||||
}
|
}
|
||||||
_value = value;
|
_value = value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,14 @@ namespace Microsoft.AspNet.Http.Abstractions
|
||||||
private static readonly ResourceManager _resourceManager
|
private static readonly ResourceManager _resourceManager
|
||||||
= new ResourceManager("Microsoft.AspNet.Http.Abstractions.Resources", typeof(Resources).GetTypeInfo().Assembly);
|
= new ResourceManager("Microsoft.AspNet.Http.Abstractions.Resources", typeof(Resources).GetTypeInfo().Assembly);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// '{0}' is not available.
|
||||||
|
/// </summary>
|
||||||
|
internal static string FormatException_PathMustStartWithSlash(object p0)
|
||||||
|
{
|
||||||
|
return string.Format(CultureInfo.CurrentCulture, GetString("Exception_PathMustStartWithSlash"), p0);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// '{0}' is not available.
|
/// '{0}' is not available.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -132,4 +132,7 @@
|
||||||
<data name="Exception_UseMiddleMutlipleInvokes" xml:space="preserve">
|
<data name="Exception_UseMiddleMutlipleInvokes" xml:space="preserve">
|
||||||
<value>Multiple public '{0}' methods are available.</value>
|
<value>Multiple public '{0}' methods are available.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Exception_PathMustStartWithSlash" xml:space="preserve">
|
||||||
|
<value>The path in '{0}' must start with '/'.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Http
|
||||||
public void CtorThrows_IfPathDoesNotHaveLeadingSlash()
|
public void CtorThrows_IfPathDoesNotHaveLeadingSlash()
|
||||||
{
|
{
|
||||||
// Act and Assert
|
// Act and Assert
|
||||||
ExceptionAssert.ThrowsArgument(() => new PathString("hello"), "value", "");
|
ExceptionAssert.ThrowsArgument(() => new PathString("hello"), "value", "The path in 'value' must start with '/'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue