forked from npgsql/npgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThrowHelper.cs
More file actions
122 lines (93 loc) · 5.1 KB
/
ThrowHelper.cs
File metadata and controls
122 lines (93 loc) · 5.1 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using Npgsql.BackendMessages;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using Npgsql.Internal;
namespace Npgsql;
static class ThrowHelper
{
[DoesNotReturn]
internal static void ThrowArgumentOutOfRangeException()
=> throw new ArgumentOutOfRangeException();
[DoesNotReturn]
internal static void ThrowArgumentOutOfRangeException(string paramName, string message)
=> throw new ArgumentOutOfRangeException(paramName, message);
[DoesNotReturn]
internal static void ThrowArgumentOutOfRangeException(string paramName, string message, object argument)
=> throw new ArgumentOutOfRangeException(paramName, string.Format(message, argument));
[DoesNotReturn]
internal static void ThrowInvalidOperationException()
=> throw new InvalidOperationException();
[DoesNotReturn]
internal static void ThrowInvalidOperationException(string message)
=> throw new InvalidOperationException(message);
[DoesNotReturn]
internal static void ThrowInvalidOperationException(string message, object argument)
=> throw new InvalidOperationException(string.Format(message, argument));
[DoesNotReturn]
internal static void ThrowObjectDisposedException(string? objectName)
=> throw new ObjectDisposedException(objectName);
[DoesNotReturn]
internal static void ThrowObjectDisposedException(string objectName, string message)
=> throw new ObjectDisposedException(objectName, message);
[DoesNotReturn]
internal static void ThrowObjectDisposedException(string objectName, Exception? innerException)
=> throw new ObjectDisposedException(objectName, innerException);
[DoesNotReturn]
internal static void ThrowInvalidCastException(string message, object argument)
=> throw new InvalidCastException(string.Format(message, argument));
[DoesNotReturn]
internal static void ThrowInvalidCastException_NoValue(FieldDescription field) =>
throw new InvalidCastException($"Column '{field.Name}' is null.");
[DoesNotReturn]
internal static void ThrowInvalidCastException(string message) =>
throw new InvalidCastException(message);
[DoesNotReturn]
internal static void ThrowInvalidCastException_NoValue() =>
throw new InvalidCastException("Field is null.");
[DoesNotReturn]
internal static void ThrowArgumentOutOfRange_OutOfColumnBounds(string paramName, int columnLength) =>
throw new ArgumentOutOfRangeException(paramName, $"The value is out of bounds from the column data, dataOffset must be between 0 and {columnLength}");
[DoesNotReturn]
internal static void ThrowInvalidOperationException_NoPropertyGetter(Type type, MemberInfo property) =>
throw new InvalidOperationException($"Composite type '{type}' cannot be written because the '{property}' property has no getter.");
[DoesNotReturn]
internal static void ThrowInvalidOperationException_NoPropertySetter(Type type, MemberInfo property) =>
throw new InvalidOperationException($"Composite type '{type}' cannot be read because the '{property}' property has no setter.");
[DoesNotReturn]
internal static void ThrowInvalidOperationException_BinaryImportParametersMismatch(int columnCount, int valueCount) =>
throw new InvalidOperationException($"The binary import operation was started with {columnCount} column(s), but {valueCount} value(s) were provided.");
[DoesNotReturn]
internal static void ThrowNpgsqlException(string message)
=> throw new NpgsqlException(message);
[DoesNotReturn]
internal static void ThrowNpgsqlException(string message, Exception? innerException)
=> throw new NpgsqlException(message, innerException);
[DoesNotReturn]
internal static void ThrowNpgsqlOperationInProgressException(NpgsqlCommand command)
=> throw new NpgsqlOperationInProgressException(command);
[DoesNotReturn]
internal static void ThrowNpgsqlOperationInProgressException(ConnectorState state)
=> throw new NpgsqlOperationInProgressException(state);
[DoesNotReturn]
internal static void ThrowArgumentException(string message)
=> throw new ArgumentException(message);
[DoesNotReturn]
internal static void ThrowArgumentException(string message, string paramName)
=> throw new ArgumentException(message, paramName);
[DoesNotReturn]
internal static void ThrowArgumentNullException(string paramName)
=> throw new ArgumentNullException(paramName);
[DoesNotReturn]
internal static void ThrowArgumentNullException(string message, string paramName)
=> throw new ArgumentNullException(paramName, message);
[DoesNotReturn]
internal static void ThrowIndexOutOfRangeException(string message)
=> throw new IndexOutOfRangeException(message);
[DoesNotReturn]
internal static void ThrowNotSupportedException(string message)
=> throw new NotSupportedException(message);
[DoesNotReturn]
internal static void ThrowNpgsqlExceptionWithInnerTimeoutException(string message)
=> throw new NpgsqlException(message, new TimeoutException());
}