-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathThrow.cs
More file actions
49 lines (47 loc) · 1.4 KB
/
Throw.cs
File metadata and controls
49 lines (47 loc) · 1.4 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
using System.ComponentModel;
using System.Globalization;
using System.Security;
namespace BytecodeApi;
internal static class Throw
{
public static Exception Argument(string parameterName, string message)
{
return new ArgumentException(message, parameterName);
}
public static Exception InvalidOperation(string message)
{
return new InvalidOperationException(message);
}
public static Exception KeyNotFound(string message)
{
return new KeyNotFoundException(message);
}
public static Exception Format(string message)
{
return new FormatException(message);
}
public static Exception InvalidEnumArgument<TEnum>(string parameterName, TEnum enumValue) where TEnum : Enum
{
return new InvalidEnumArgumentException(parameterName, Convert.ToInt32(enumValue), typeof(TEnum));
}
public static Exception UnsupportedType(string parameterName)
{
return new NotSupportedException(string.Format(CultureInfo.InvariantCulture, ExceptionMessages.UnsupportedType, parameterName));
}
public static Exception WrongPassword()
{
return new SecurityException(ExceptionMessages.Security.WrongPassword);
}
public static Exception Win32()
{
return new Win32Exception(ExceptionMessages.Win32);
}
public static Exception Win32(string message)
{
return new Win32Exception(message);
}
public static Exception Win32(int error)
{
return new Win32Exception(error);
}
}