Skip to content

Commit 1d68297

Browse files
committed
Simplify exception handlong with new guards
1 parent 1739185 commit 1d68297

File tree

4 files changed

+5
-22
lines changed

4 files changed

+5
-22
lines changed

src/LinkDotNet.Blog.Domain/Enumeration.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ protected Enumeration()
1414

1515
protected Enumeration(string key)
1616
{
17-
if (string.IsNullOrWhiteSpace(key))
18-
{
19-
throw new ArgumentException("The enum key cannot be null or empty", nameof(key));
20-
}
21-
17+
ArgumentException.ThrowIfNullOrWhiteSpace(key);
2218
Key = key;
2319
}
2420

src/LinkDotNet.Blog.Domain/ProfileInformationEntry.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ private ProfileInformationEntry()
1616

1717
public static ProfileInformationEntry Create(string key, int sortOrder)
1818
{
19-
if (string.IsNullOrWhiteSpace(key))
20-
{
21-
throw new ArgumentNullException(nameof(key));
22-
}
19+
ArgumentException.ThrowIfNullOrWhiteSpace(key);
2320

2421
return new ProfileInformationEntry
2522
{

src/LinkDotNet.Blog.Domain/Skill.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,8 @@ private Skill(string name, string iconUrl, string capability, ProficiencyLevel p
2626

2727
public static Skill Create(string name, string iconUrl, string capability, string proficiencyLevel)
2828
{
29-
if (string.IsNullOrWhiteSpace(name))
30-
{
31-
throw new ArgumentNullException(nameof(name));
32-
}
33-
34-
if (string.IsNullOrWhiteSpace(capability))
35-
{
36-
throw new ArgumentNullException(nameof(capability));
37-
}
29+
ArgumentException.ThrowIfNullOrWhiteSpace(name);
30+
ArgumentException.ThrowIfNullOrWhiteSpace(capability);
3831

3932
var level = ProficiencyLevel.Create(proficiencyLevel);
4033

src/LinkDotNet.Blog.Domain/Tag.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ private Tag()
1414

1515
public static Tag Create(string content)
1616
{
17-
if (string.IsNullOrWhiteSpace(content))
18-
{
19-
throw new ArgumentNullException(nameof(content));
20-
}
17+
ArgumentException.ThrowIfNullOrWhiteSpace(content);
2118

2219
return new Tag
2320
{

0 commit comments

Comments
 (0)