Skip to content

Commit

Permalink
SWEEP: Reviewed all catch blocks where Lucene uses Error and converte…
Browse files Browse the repository at this point in the history
…d them to use our IsError() extension method (see apache#446).
  • Loading branch information
NightOwl888 committed Apr 14, 2021
1 parent 7a54ea5 commit 3c602c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public IQueryNode Parse(string query, string field)
tme.SetQuery(query);
throw tme;
}
catch (Exception tme)
catch (Exception tme) when (tme.IsError())
{
IMessage message = new Message(QueryParserMessages.INVALID_SYNTAX_CANNOT_PARSE, query, tme.Message);
QueryNodeParseException e = new QueryNodeParseException(tme);
Expand Down
16 changes: 8 additions & 8 deletions src/Lucene.Net.Tests/Search/TestDisjunctionMaxQuery.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Globalization;
using Lucene.Net.Documents;
using Lucene.Net.Index.Extensions;
Expand Down Expand Up @@ -245,7 +245,7 @@ public virtual void TestSimpleEqualScores1()
Assert.AreEqual(score, h[i].Score, SCORE_COMP_THRESH, "score #" + i + " is not the same");
}
}
catch (Exception /*e*/)
catch (Exception e) when (e.IsError())
{
PrintHits("testSimpleEqualScores1", h, s);
throw; // LUCENENET: CA2200: Rethrow to preserve stack details (https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200-rethrow-to-preserve-stack-details)
Expand Down Expand Up @@ -275,7 +275,7 @@ public virtual void TestSimpleEqualScores2()
Assert.AreEqual(score, h[i].Score, SCORE_COMP_THRESH, "score #" + i + " is not the same");
}
}
catch (Exception /*e*/)
catch (Exception e) when (e.IsError())
{
PrintHits("testSimpleEqualScores2", h, s);
throw; // LUCENENET: CA2200: Rethrow to preserve stack details (https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200-rethrow-to-preserve-stack-details)
Expand Down Expand Up @@ -307,7 +307,7 @@ public virtual void TestSimpleEqualScores3()
Assert.AreEqual(score, h[i].Score, SCORE_COMP_THRESH, "score #" + i + " is not the same");
}
}
catch (Exception /*e*/)
catch (Exception e) when (e.IsError())
{
PrintHits("testSimpleEqualScores3", h, s);
throw; // LUCENENET: CA2200: Rethrow to preserve stack details (https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200-rethrow-to-preserve-stack-details)
Expand Down Expand Up @@ -338,7 +338,7 @@ public virtual void TestSimpleTiebreaker()
Assert.IsTrue(score0 > score1, "d2 does not have better score then others: " + score0 + " >? " + score1);
Assert.AreEqual(score1, score2, SCORE_COMP_THRESH, "d4 and d1 don't have equal scores");
}
catch (Exception /*e*/)
catch (Exception e) when (e.IsError())
{
PrintHits("testSimpleTiebreaker", h, s);
throw; // LUCENENET: CA2200: Rethrow to preserve stack details (https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200-rethrow-to-preserve-stack-details)
Expand Down Expand Up @@ -389,7 +389,7 @@ public virtual void TestBooleanRequiredEqualScores()
Assert.AreEqual(score, h[i].Score, SCORE_COMP_THRESH, "score #" + i + " is not the same");
}
}
catch (Exception /*e*/)
catch (Exception e) when (e.IsError())
{
PrintHits("testBooleanRequiredEqualScores1", h, s);
throw; // LUCENENET: CA2200: Rethrow to preserve stack details (https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200-rethrow-to-preserve-stack-details)
Expand Down Expand Up @@ -432,7 +432,7 @@ public virtual void TestBooleanOptionalNoTiebreaker()
float score1 = h[h.Length - 1].Score;
Assert.IsTrue(score > score1, "d1 does not have worse score then others: " + score + " >? " + score1);
}
catch (Exception /*e*/)
catch (Exception e) when (e.IsError())
{
PrintHits("testBooleanOptionalNoTiebreaker", h, s);
throw; // LUCENENET: CA2200: Rethrow to preserve stack details (https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200-rethrow-to-preserve-stack-details)
Expand Down Expand Up @@ -486,7 +486,7 @@ public virtual void TestBooleanOptionalWithTiebreaker()
Assert.AreEqual("d1", doc3, "wrong fourth");
Assert.IsTrue(score2 > score3, "d1 does not have worse score then d3: " + score2 + " >? " + score3);
}
catch (Exception /*e*/)
catch (Exception e) when (e.IsError())
{
PrintHits("testBooleanOptionalWithTiebreaker", h, s);
throw; // LUCENENET: CA2200: Rethrow to preserve stack details (https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200-rethrow-to-preserve-stack-details)
Expand Down

0 comments on commit 3c602c5

Please sign in to comment.