-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathExceptionHelper.cs
More file actions
53 lines (48 loc) · 1.05 KB
/
ExceptionHelper.cs
File metadata and controls
53 lines (48 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
namespace rm.Extensions;
/// <summary>
/// Exception helper class.
/// </summary>
internal class ExceptionHelper
{
/// <summary>
/// Throws NullReferenceException if true with message.
/// </summary>
internal static void ThrowIfNull(bool throwEx, string exMessage)
{
if (throwEx)
{
throw new NullReferenceException(exMessage);
}
}
/// <summary>
/// Throws ArgumentNullException if true with message.
/// </summary>
internal static void ThrowIfArgumentNull(bool throwEx, string exMessage)
{
if (throwEx)
{
throw new ArgumentNullException(exMessage);
}
}
/// <summary>
/// Throws EmptyException if true with message.
/// </summary>
internal static void ThrowIfEmpty(bool throwEx, string exMessage)
{
if (throwEx)
{
throw new EmptyException(exMessage);
}
}
/// <summary>
/// Throws ArgumentOutOfRangeException if true with message.
/// </summary>
internal static void ThrowIfArgumentOutOfRange(bool throwEx, string exMessage)
{
if (throwEx)
{
throw new ArgumentOutOfRangeException(exMessage);
}
}
}