Skip to content

Commit

Permalink
SWEEP: Reviewed all catch blocks where Lucene uses IllegalArgumentExc…
Browse files Browse the repository at this point in the history
…eption and converted them to use our IsIllegalArgumentException() extension method (see apache#446).
  • Loading branch information
NightOwl888 committed Apr 14, 2021
1 parent afe277f commit 0756ba7
Show file tree
Hide file tree
Showing 171 changed files with 509 additions and 715 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Util;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -134,7 +134,7 @@ public override void Parse(TextReader @in)
}
}
}
catch (ArgumentException e)
catch (Exception e) when (e.IsIllegalArgumentException())
{
throw new Exception("Invalid synonym rule at line " + lineNumber, e);
//ex.initCause(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Util;
using System;
using System.IO;
Expand Down Expand Up @@ -78,7 +78,7 @@ public override void Parse(TextReader @in)
// final synset in the file
AddInternal(synset, synsetSize);
}
catch (ArgumentException e)
catch (Exception e) when (e.IsIllegalArgumentException())
{
throw new Exception("Invalid synonym rule at line " + lineNumber.ToString(), e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ private static IDictionary<string, IList<Rule>> ParseRules(TextReader reader, st
}
rules.Add(r);
}
catch (ArgumentException e)
catch (Exception e) when (e.IsIllegalArgumentException())
{
throw new InvalidOperationException("Problem parsing line '" + currentLine + "' in " +
location, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ private static void ParseRules(TextReader scanner, string location,
}
rules.Add(r);
}
catch (ArgumentException e)
catch (Exception e) when (e.IsIllegalArgumentException())
{
throw new InvalidOperationException(
"Problem parsing line '" + currentLine + "' in " + location, e);
Expand Down
6 changes: 3 additions & 3 deletions src/Lucene.Net.Benchmark/ByTask/Tasks/AnalyzerFactoryTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public override void SetParams(string @params)
clazz = LookupAnalysisClass(argName, typeof(CharFilterFactory));
CreateAnalysisPipelineComponent(stok, clazz);
}
catch (ArgumentException /*e*/)
catch (Exception e) when (e.IsIllegalArgumentException())
{
try
{
Expand All @@ -313,7 +313,7 @@ public override void SetParams(string @params)
CreateAnalysisPipelineComponent(stok, clazz);
expectedArgType = ArgType.TOKENFILTER;
}
catch (ArgumentException e2)
catch (Exception e2) when (e2.IsIllegalArgumentException())
{
throw new Exception("Line #" + GetLineNumber(stok) + ": Can't find class '"
+ argName + "' as CharFilterFactory or TokenizerFactory", e2);
Expand All @@ -328,7 +328,7 @@ public override void SetParams(string @params)
{
clazz = LookupAnalysisClass(className, typeof(TokenFilterFactory));
}
catch (ArgumentException e)
catch (Exception e) when (e.IsIllegalArgumentException())
{
throw new Exception
("Line #" + GetLineNumber(stok) + ": Can't find class '" + className + "' as TokenFilterFactory", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3076,7 +3076,7 @@ public virtual void TestHugeBinaryValues()
{
w.AddDocument(doc);
}
catch (ArgumentException iae)
catch (Exception iae) when (iae.IsIllegalArgumentException())
{
if (iae.Message.IndexOf("is too large", StringComparison.Ordinal) == -1)
{
Expand All @@ -3099,7 +3099,7 @@ public virtual void TestHugeBinaryValues()
{
r = w.GetReader();
}
catch (ArgumentException iae)
catch (Exception iae) when (iae.IsIllegalArgumentException())
{
if (iae.Message.IndexOf("is too large", StringComparison.Ordinal) == -1)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Util;
using NUnit.Framework;
using System;
Expand Down Expand Up @@ -86,7 +86,7 @@ public virtual void TestBogusArguments()
TokenFilterFactory("ArabicNormalization", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand All @@ -96,7 +96,7 @@ public virtual void TestBogusArguments()
TokenFilterFactory("Arabicstem", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand All @@ -106,7 +106,7 @@ public virtual void TestBogusArguments()
CharFilterFactory("Persian", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand All @@ -116,7 +116,7 @@ public virtual void TestBogusArguments()
TokenizerFactory("ArabicLetter", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Util;
using NUnit.Framework;
using System;
Expand Down Expand Up @@ -50,7 +50,7 @@ public virtual void TestBogusArguments()
TokenFilterFactory("BulgarianStem", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Util;
using NUnit.Framework;
using System;
Expand Down Expand Up @@ -50,7 +50,7 @@ public virtual void TestBogusArguments()
TokenFilterFactory("BrazilianStem", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Util;
using NUnit.Framework;
using System;
Expand Down Expand Up @@ -105,7 +105,7 @@ public virtual void TestBogusArguments()
CharFilterFactory("HTMLStrip", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Util;
using NUnit.Framework;
using System;
Expand Down Expand Up @@ -35,7 +35,7 @@ public virtual void TestParseString()
f.ParseString("\\");
fail("escape character cannot be alone.");
}
catch (ArgumentException)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
}

Expand All @@ -48,7 +48,7 @@ public virtual void TestParseString()
f.ParseString("\\u000");
fail("invalid length check.");
}
catch (ArgumentException)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
}

Expand All @@ -72,7 +72,7 @@ public virtual void TestBogusArguments()
CharFilterFactory("Mapping", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using System;
using NUnit.Framework;
using Lucene.Net.Analysis.Util;
Expand Down Expand Up @@ -65,7 +65,7 @@ public virtual void TestBogusArguments()
TokenFilterFactory("CJKBigram", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Util;
using NUnit.Framework;
using System;
Expand Down Expand Up @@ -50,7 +50,7 @@ public virtual void TestBogusArguments()
TokenizerFactory("CJK", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Util;
using NUnit.Framework;
using System;
Expand Down Expand Up @@ -47,7 +47,7 @@ public virtual void TestBogusArguments()
TokenFilterFactory("CJKWidth", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Util;
using NUnit.Framework;
using System;
Expand Down Expand Up @@ -48,7 +48,7 @@ public virtual void TestBogusArguments()
TokenFilterFactory("SoraniNormalization", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Util;
using NUnit.Framework;
using System;
Expand Down Expand Up @@ -48,7 +48,7 @@ public virtual void TestBogusArguments()
TokenFilterFactory("SoraniStem", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using System;
using System.IO;
using NUnit.Framework;
Expand Down Expand Up @@ -50,7 +50,7 @@ public virtual void TestBogusArguments()
TokenFilterFactory("Chinese", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using System;
using System.IO;
using NUnit.Framework;
Expand Down Expand Up @@ -49,7 +49,7 @@ public virtual void TestBogusArguments()
TokenizerFactory("Chinese", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Util;
using NUnit.Framework;
Expand Down Expand Up @@ -89,7 +89,7 @@ public virtual void TestBogusArguments()
TokenFilterFactory("CommonGrams", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Util;
using NUnit.Framework;
Expand Down Expand Up @@ -89,7 +89,7 @@ public virtual void TestBogusArguments()
TokenFilterFactory("CommonGramsQuery", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Util;
using System;
using System.IO;
Expand Down Expand Up @@ -50,7 +50,7 @@ public virtual void TestBogusArguments()
TokenFilterFactory("DictionaryCompoundWord", "dictionary", "compoundDictionary.txt", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Util;
using NUnit.Framework;
using System;
Expand Down Expand Up @@ -66,7 +66,7 @@ public virtual void TestBogusArguments()
TokenFilterFactory("HyphenationCompoundWord", "hyphenator", "da_UTF8.xml", "bogusArg", "bogusValue");
fail();
}
catch (ArgumentException expected)
catch (Exception expected) when (expected.IsIllegalArgumentException())
{
assertTrue(expected.Message.Contains("Unknown parameters"));
}
Expand Down
Loading

0 comments on commit 0756ba7

Please sign in to comment.