Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit d4d04d2

Browse files
committed
Adding exception message for paths not starting with / #251
1 parent d25c25c commit d4d04d2

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

src/Microsoft.AspNet.Http.Abstractions/PathString.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Text.Encodings.Web;
6+
using Microsoft.AspNet.Http.Abstractions;
67

78
namespace Microsoft.AspNet.Http
89
{
@@ -29,7 +30,7 @@ public PathString(string value)
2930
{
3031
if (!string.IsNullOrEmpty(value) && value[0] != '/')
3132
{
32-
throw new ArgumentException(""/*Resources.Exception_PathMustStartWithSlash*/, nameof(value));
33+
throw new ArgumentException(Resources.FormatException_PathMustStartWithSlash(nameof(value)), nameof(value));
3334
}
3435
_value = value;
3536
}

src/Microsoft.AspNet.Http.Abstractions/Properties/Resources.Designer.cs

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Microsoft.AspNet.Http.Abstractions/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,7 @@
132132
<data name="Exception_UseMiddleMutlipleInvokes" xml:space="preserve">
133133
<value>Multiple public '{0}' methods are available.</value>
134134
</data>
135+
<data name="Exception_PathMustStartWithSlash" xml:space="preserve">
136+
<value>The path in '{0}' must start with '/'.</value>
137+
</data>
135138
</root>

test/Microsoft.AspNet.Http.Abstractions.Tests/PathStringTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class PathStringTests
1313
public void CtorThrows_IfPathDoesNotHaveLeadingSlash()
1414
{
1515
// Act and Assert
16-
ExceptionAssert.ThrowsArgument(() => new PathString("hello"), "value", "");
16+
ExceptionAssert.ThrowsArgument(() => new PathString("hello"), "value", "The path in 'value' must start with '/'.");
1717
}
1818

1919
[Theory]

0 commit comments

Comments
 (0)