Skip to content

Commit e1fde7a

Browse files
Merge branch 'master' into GH948New
2 parents 310644f + 699db48 commit e1fde7a

File tree

17 files changed

+78
-71
lines changed

17 files changed

+78
-71
lines changed

src/NHibernate.DomainModel/Foo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public FooComponent Component
322322
public FooComponent NullComponent
323323
{
324324
get { return null; }
325-
set { if (value != null) throw new Exception("Null component"); }
325+
set { if (value != null) throw new ArgumentException("Null component"); }
326326
}
327327

328328
#endregion
@@ -432,4 +432,4 @@ public bool EqualsFoo(Foo other)
432432

433433
private static int count = 0;
434434
}
435-
}
435+
}

src/NHibernate.DomainModel/FooComponent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private String NullString
110110
set
111111
{
112112
if (value != null)
113-
throw new Exception("null component property");
113+
throw new ArgumentException("null component property");
114114
}
115115
}
116116

@@ -179,4 +179,4 @@ public override string ToString()
179179

180180
#endregion
181181
}
182-
}
182+
}

src/NHibernate.Test/Async/NHSpecificTest/NH2583/Domain.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public partial class MyBO
7878
set(await (bo.GetOrCreateBO1Async(s, cancellationToken)), 1);
7979
break;
8080
default:
81-
throw new Exception("Value " + value + " not handled in code");
81+
throw new NotImplementedException("Value " + value + " not handled in code");
8282
}
8383
}
8484

@@ -114,7 +114,7 @@ public partial class MyBO
114114
set(await (bo.GetOrCreateBO2Async(s, cancellationToken)), 1);
115115
break;
116116
default:
117-
throw new Exception("Value " + value + " not handled in code");
117+
throw new NotImplementedException("Value " + value + " not handled in code");
118118
}
119119
}
120120

@@ -153,7 +153,7 @@ public partial class MyBO
153153
set(await ((await (bo.GetOrCreateBO1Async(s, cancellationToken))).GetOrCreateBO2Async(s, cancellationToken)), 1);
154154
break;
155155
default:
156-
throw new Exception("Value " + value + " not handled in code");
156+
throw new NotImplementedException("Value " + value + " not handled in code");
157157
}
158158
}
159159

@@ -187,7 +187,7 @@ public partial class MyBO
187187
(await ((await (bo.GetOrCreateBO1Async(s, cancellationToken))).GetOrCreateBO3Async(s, cancellationToken))).L1 = 1;
188188
break;
189189
default:
190-
throw new Exception("Value " + value + " not handled in code");
190+
throw new NotImplementedException("Value " + value + " not handled in code");
191191
}
192192
}
193193
}

src/NHibernate.Test/Async/QueryTest/DetachedQueryFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public Dictionary<string, TypedValue> NamedListParams
260260

261261
public override IQuery GetExecutableQuery(ISession session)
262262
{
263-
throw new Exception("The method or operation is not implemented.");
263+
throw new NotImplementedException("The method or operation is not implemented.");
264264
}
265265

266266
public new void CopyTo(IDetachedQuery destination)

src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void SimpleCriterion_NoAlias()
4747
public static int CompareString(string left, string right, bool textCompare)
4848
{
4949
// could consider calling Microsoft.VisualBasic.CompilerServices.Operators.CompareString
50-
throw new Exception("This is just here to allow us to simulate the VB.Net LINQ expression tree");
50+
throw new InvalidOperationException("This is just here to allow us to simulate the VB.Net LINQ expression tree");
5151
}
5252

5353
[Test]

src/NHibernate.Test/DynamicProxyTests/PeVerifier.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public PeVerifier(string assemblyFileName)
2626
while (!Directory.Exists(Path.Combine(dir, "Tools", "PEVerify")))
2727
{
2828
if (Directory.GetParent(dir) == null)
29-
throw new Exception(string.Format("Could not find Tools/PEVerify directory in ancestor of {0}", _assemlyLocation));
29+
throw new DirectoryNotFoundException(string.Format("Could not find Tools/PEVerify directory in ancestor of {0}", _assemlyLocation));
3030

3131
dir = Directory.GetParent(dir).FullName;
3232
}
@@ -38,7 +38,7 @@ public PeVerifier(string assemblyFileName)
3838
_peVerifyPath = Path.Combine(dir, "Tools", "PEVerify", versionFolder, "PEVerify.exe");
3939

4040
if (!File.Exists(_peVerifyPath))
41-
throw new Exception(string.Format("Could not find PEVerify.exe at {0}", _peVerifyPath));
41+
throw new FileNotFoundException(string.Format("Could not find PEVerify.exe at {0}", _peVerifyPath));
4242
}
4343

4444
public void AssertIsValid()

src/NHibernate.Test/LogSpy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public LogSpy(ILog log, Level level)
1919
logger = log.Logger as Logger;
2020
if (logger == null)
2121
{
22-
throw new Exception("Unable to get the logger");
22+
throw new InvalidOperationException("Unable to get the logger");
2323
}
2424

2525
// Change the log level to DEBUG and temporarily save the previous log level

src/NHibernate.Test/NHSpecificTest/NH2583/Domain.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public static void SetK1(MyBO bo, ISession s, TK value)
153153
bo.K1 = 1;
154154
break;
155155
default:
156-
throw new Exception("Value " + value + " not handled in code");
156+
throw new NotImplementedException("Value " + value + " not handled in code");
157157
}
158158
}
159159

@@ -184,7 +184,7 @@ private static void SetBO1_I(MyBO bo, ISession s, TBO1_I value, Action<MyRef1, i
184184
set(bo.GetOrCreateBO1(s), 1);
185185
break;
186186
default:
187-
throw new Exception("Value " + value + " not handled in code");
187+
throw new NotImplementedException("Value " + value + " not handled in code");
188188
}
189189
}
190190

@@ -220,7 +220,7 @@ private static void SetBO2_J(MyBO bo, ISession s, TBO2_J value, Action<MyRef2, i
220220
set(bo.GetOrCreateBO2(s), 1);
221221
break;
222222
default:
223-
throw new Exception("Value " + value + " not handled in code");
223+
throw new NotImplementedException("Value " + value + " not handled in code");
224224
}
225225
}
226226

@@ -259,7 +259,7 @@ private static void SetBO1_BO2_J(MyBO bo, ISession s, TBO1_BO2_J value, Action<M
259259
set(bo.GetOrCreateBO1(s).GetOrCreateBO2(s), 1);
260260
break;
261261
default:
262-
throw new Exception("Value " + value + " not handled in code");
262+
throw new NotImplementedException("Value " + value + " not handled in code");
263263
}
264264
}
265265

@@ -293,7 +293,7 @@ public static void SetBO1_BO3_L1(MyBO bo, ISession s, TBO1_BO3_L value)
293293
bo.GetOrCreateBO1(s).GetOrCreateBO3(s).L1 = 1;
294294
break;
295295
default:
296-
throw new Exception("Value " + value + " not handled in code");
296+
throw new NotImplementedException("Value " + value + " not handled in code");
297297
}
298298
}
299299
}

src/NHibernate.Test/QueryTest/DetachedQueryFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ public Dictionary<string, TypedValue> NamedListParams
544544

545545
public override IQuery GetExecutableQuery(ISession session)
546546
{
547-
throw new Exception("The method or operation is not implemented.");
547+
throw new NotImplementedException("The method or operation is not implemented.");
548548
}
549549

550550
public new void CopyTo(IDetachedQuery destination)

src/NHibernate/Criterion/Projections.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ public static AggregateProjection Sum(Expression<Func<object>> expression)
494494
/// </summary>
495495
public static string Concat(params string[] strings)
496496
{
497-
throw new Exception("Not to be used directly - use inside QueryOver expression");
497+
throw QueryOver.GetDirectUsageException();
498498
}
499499

500500
internal static IProjection ProcessConcat(MethodCallExpression methodCallExpression)

src/NHibernate/Criterion/ProjectionsExtensions.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ internal static IProjection ProcessDate(System.Linq.Expressions.Expression expre
8181
/// </summary>
8282
public static double Sqrt(this double numericProperty)
8383
{
84-
throw new Exception("Not to be used directly - use inside QueryOver expression");
84+
throw QueryOver.GetDirectUsageException();
8585
}
8686

8787
/// <summary>
@@ -90,7 +90,7 @@ public static double Sqrt(this double numericProperty)
9090
/// </summary>
9191
public static double Sqrt(this int numericProperty)
9292
{
93-
throw new Exception("Not to be used directly - use inside QueryOver expression");
93+
throw QueryOver.GetDirectUsageException();
9494
}
9595

9696
/// <summary>
@@ -99,7 +99,7 @@ public static double Sqrt(this int numericProperty)
9999
/// </summary>
100100
public static double Sqrt(this long numericProperty)
101101
{
102-
throw new Exception("Not to be used directly - use inside QueryOver expression");
102+
throw QueryOver.GetDirectUsageException();
103103
}
104104

105105
/// <summary>
@@ -108,7 +108,7 @@ public static double Sqrt(this long numericProperty)
108108
/// </summary>
109109
public static double Sqrt(this decimal numericProperty)
110110
{
111-
throw new Exception("Not to be used directly - use inside QueryOver expression");
111+
throw QueryOver.GetDirectUsageException();
112112
}
113113

114114
/// <summary>
@@ -117,7 +117,7 @@ public static double Sqrt(this decimal numericProperty)
117117
/// </summary>
118118
public static double Sqrt(this byte numericProperty)
119119
{
120-
throw new Exception("Not to be used directly - use inside QueryOver expression");
120+
throw QueryOver.GetDirectUsageException();
121121
}
122122

123123
internal static IProjection ProcessSqrt(MethodCallExpression methodCallExpression)
@@ -132,7 +132,7 @@ internal static IProjection ProcessSqrt(MethodCallExpression methodCallExpressio
132132
/// </summary>
133133
public static string Lower(this string stringProperty)
134134
{
135-
throw new Exception("Not to be used directly - use inside QueryOver expression");
135+
throw QueryOver.GetDirectUsageException();
136136
}
137137

138138
internal static IProjection ProcessLower(MethodCallExpression methodCallExpression)
@@ -147,7 +147,7 @@ internal static IProjection ProcessLower(MethodCallExpression methodCallExpressi
147147
/// </summary>
148148
public static string Upper(this string stringProperty)
149149
{
150-
throw new Exception("Not to be used directly - use inside QueryOver expression");
150+
throw QueryOver.GetDirectUsageException();
151151
}
152152

153153
internal static IProjection ProcessUpper(MethodCallExpression methodCallExpression)
@@ -162,7 +162,7 @@ internal static IProjection ProcessUpper(MethodCallExpression methodCallExpressi
162162
/// </summary>
163163
public static int Abs(this int numericProperty)
164164
{
165-
throw new Exception("Not to be used directly - use inside QueryOver expression");
165+
throw QueryOver.GetDirectUsageException();
166166
}
167167

168168
internal static IProjection ProcessIntAbs(MethodCallExpression methodCallExpression)
@@ -177,7 +177,7 @@ internal static IProjection ProcessIntAbs(MethodCallExpression methodCallExpress
177177
/// </summary>
178178
public static Int64 Abs(this Int64 numericProperty)
179179
{
180-
throw new Exception("Not to be used directly - use inside QueryOver expression");
180+
throw QueryOver.GetDirectUsageException();
181181
}
182182

183183
internal static IProjection ProcessInt64Abs(MethodCallExpression methodCallExpression)
@@ -206,7 +206,7 @@ internal static IProjection ProcessRound(MethodCallExpression methodCallExpressi
206206
/// </summary>
207207
public static double Abs(this double numericProperty)
208208
{
209-
throw new Exception("Not to be used directly - use inside QueryOver expression");
209+
throw QueryOver.GetDirectUsageException();
210210
}
211211

212212
internal static IProjection ProcessDoubleAbs(MethodCallExpression methodCallExpression)
@@ -221,7 +221,7 @@ internal static IProjection ProcessDoubleAbs(MethodCallExpression methodCallExpr
221221
/// </summary>
222222
public static string TrimStr(this string stringProperty)
223223
{
224-
throw new Exception("Not to be used directly - use inside QueryOver expression");
224+
throw QueryOver.GetDirectUsageException();
225225
}
226226

227227
internal static IProjection ProcessTrimStr(MethodCallExpression methodCallExpression)
@@ -236,7 +236,7 @@ internal static IProjection ProcessTrimStr(MethodCallExpression methodCallExpres
236236
/// </summary>
237237
public static int StrLength(this string stringProperty)
238238
{
239-
throw new Exception("Not to be used directly - use inside QueryOver expression");
239+
throw QueryOver.GetDirectUsageException();
240240
}
241241

242242
internal static IProjection ProcessStrLength(MethodCallExpression methodCallExpression)
@@ -251,7 +251,7 @@ internal static IProjection ProcessStrLength(MethodCallExpression methodCallExpr
251251
/// </summary>
252252
public static int BitLength(this string stringProperty)
253253
{
254-
throw new Exception("Not to be used directly - use inside QueryOver expression");
254+
throw QueryOver.GetDirectUsageException();
255255
}
256256

257257
internal static IProjection ProcessBitLength(MethodCallExpression methodCallExpression)
@@ -266,7 +266,7 @@ internal static IProjection ProcessBitLength(MethodCallExpression methodCallExpr
266266
/// </summary>
267267
public static string Substr(this string stringProperty, int startIndex, int length)
268268
{
269-
throw new Exception("Not to be used directly - use inside QueryOver expression");
269+
throw QueryOver.GetDirectUsageException();
270270
}
271271

272272
internal static IProjection ProcessSubstr(MethodCallExpression methodCallExpression)
@@ -283,7 +283,7 @@ internal static IProjection ProcessSubstr(MethodCallExpression methodCallExpress
283283
/// </summary>
284284
public static int CharIndex(this string stringProperty, string theChar, int startLocation)
285285
{
286-
throw new Exception("Not to be used directly - use inside QueryOver expression");
286+
throw QueryOver.GetDirectUsageException();
287287
}
288288

289289
internal static IProjection ProcessCharIndex(MethodCallExpression methodCallExpression)
@@ -300,7 +300,7 @@ internal static IProjection ProcessCharIndex(MethodCallExpression methodCallExpr
300300
/// </summary>
301301
public static T Coalesce<T>(this T objectProperty, T replaceValueIfIsNull)
302302
{
303-
throw new Exception("Not to be used directly - use inside QueryOver expression");
303+
throw QueryOver.GetDirectUsageException();
304304
}
305305

306306
/// <summary>
@@ -309,7 +309,7 @@ public static T Coalesce<T>(this T objectProperty, T replaceValueIfIsNull)
309309
/// </summary>
310310
public static T? Coalesce<T>(this T? objectProperty, T replaceValueIfIsNull) where T : struct
311311
{
312-
throw new Exception("Not to be used directly - use inside QueryOver expression");
312+
throw QueryOver.GetDirectUsageException();
313313
}
314314

315315
internal static IProjection ProcessCoalesce(MethodCallExpression methodCallExpression)
@@ -325,7 +325,7 @@ internal static IProjection ProcessCoalesce(MethodCallExpression methodCallExpre
325325
/// </summary>
326326
public static int Mod(this int numericProperty, int divisor)
327327
{
328-
throw new Exception("Not to be used directly - use inside QueryOver expression");
328+
throw QueryOver.GetDirectUsageException();
329329
}
330330

331331
internal static IProjection ProcessMod(MethodCallExpression methodCallExpression)

src/NHibernate/Criterion/QueryOver.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public DetachedCriteria DetachedCriteria
5656
get { return new DetachedCriteria(impl, impl); }
5757
}
5858

59+
internal static Exception GetDirectUsageException()
60+
{
61+
return new InvalidOperationException("Not to be used directly - use inside QueryOver expression");
62+
}
5963
}
6064

6165
[Serializable]

0 commit comments

Comments
 (0)