Skip to content

Commit

Permalink
SWEEP: Changed all applicable Error creation statements to Error.Crea…
Browse files Browse the repository at this point in the history
…te() (see #446)
  • Loading branch information
NightOwl888 committed Apr 26, 2021
1 parent 0bb6eb8 commit 0257003
Show file tree
Hide file tree
Showing 23 changed files with 77 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31146,7 +31146,7 @@ private void ZzScanError(int errorCode)
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}

throw new Error(message);
throw Error.Create(message);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ private void ZzScanError(int errorCode)
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}

throw new Error(message);
throw Error.Create(message);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ private void ZzScanError(int errorCode)
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}

throw new Error(message);
throw Error.Create(message);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ private void ZzScanError(int errorCode)
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}

throw new Error(message);
throw Error.Create(message);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3480,7 +3480,7 @@ private void ZzScanError(int errorCode)
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}

throw new Error(message);
throw Error.Create(message);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ private void ZzScanError(int errorCode)
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}

throw new Error(message);
throw Error.Create(message);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3594,7 +3594,7 @@ private void ZzScanError(int errorCode)
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}

throw new Error(message);
throw Error.Create(message);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4031,7 +4031,7 @@ private void ZzScanError(int errorCode)
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}

throw new Error(message);
throw Error.Create(message);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ private void ZzScanError(int errorCode)
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}

throw new Error(message);
throw Error.Create(message);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4249,7 +4249,7 @@ private void ZzScanError(int errorCode)
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}

throw new Error(message);
throw Error.Create(message);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9356,7 +9356,7 @@ private void ZzScanError(int errorCode)
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}

throw new Error(message);
throw Error.Create(message);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ private void ZzScanError(int errorCode)
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}

throw new Error(message);
throw Error.Create(message);
}


Expand Down
6 changes: 3 additions & 3 deletions src/Lucene.Net.Expressions/JS/JavascriptCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ private static IDictionary<string, MethodInfo> LoadDefaultFunctions() // LUCENEN
string[] vals = property.Value.Split(',').TrimEnd();
if (vals.Length != 3)
{
throw new Exception("Error reading Javascript functions from settings");
throw Error.Create("Error reading Javascript functions from settings");
}
string typeName = vals[0];

Expand All @@ -627,9 +627,9 @@ private static IDictionary<string, MethodInfo> LoadDefaultFunctions() // LUCENEN
map[property.Key] = method;
}
}
catch (Exception e) // LUCENENET specific: Just wrapping everything in Exception. I don't think it makes any difference here.
catch (Exception e) when (e.IsNoSuchMethodException() || e.IsClassNotFoundException() || e.IsIOException())
{
throw new Exception("Cannot resolve function", e);
throw Error.Create("Cannot resolve function", e);
}
return map.AsReadOnly();
}
Expand Down
15 changes: 8 additions & 7 deletions src/Lucene.Net.QueryParser/Classic/QueryParser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Lucene.Net.Analysis;
using Lucene.Net.Analysis;
using Lucene.Net.Search;
using Lucene.Net.Util;
using System;
Expand Down Expand Up @@ -157,7 +157,7 @@ public int Conjunction()
{
if (true) return ret;
}
throw new InvalidOperationException("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public int Modifiers()
Expand Down Expand Up @@ -195,7 +195,7 @@ public int Modifiers()
{
if (true) return ret;
}
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

// This makes sure that there is no garbage after the query string
Expand All @@ -207,7 +207,7 @@ public override sealed Query TopLevelQuery(string field)
{
if (true) return q;
}
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public Query Query(string field)
Expand Down Expand Up @@ -259,7 +259,8 @@ public Query Query(string field)
if (true) return firstQuery;
}

return GetBooleanQuery(clauses);
if (true) return GetBooleanQuery(clauses);
throw Error.Create("Missing return statement in function");
}

public Query Clause(string field)
Expand Down Expand Up @@ -327,7 +328,7 @@ public Query Clause(string field)
{
if (true) return HandleBoost(q, boost);
}
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public Query Term(string field)
Expand Down Expand Up @@ -538,7 +539,7 @@ public Query Term(string field)
throw new ParseException();
}
{ if (true) return HandleBoost(q, boost); }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

private bool Jj_2_1(int xla)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public int Conjunction()
break;
}
{ if (true) return ret; }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public Modifier Modifiers()
Expand Down Expand Up @@ -148,7 +148,7 @@ public Modifier Modifiers()
break;
}
{ if (true) return ret; }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

// This makes sure that there is no garbage after the query string
Expand All @@ -158,7 +158,7 @@ public IQueryNode TopLevelQuery(string field)
q = Query(field);
Jj_consume_token(0);
{ if (true) return q; }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}


Expand Down Expand Up @@ -215,7 +215,7 @@ public IQueryNode Query(string field)
{
{ if (true) return first; }
}
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public IQueryNode DisjQuery(string field)
Expand Down Expand Up @@ -253,7 +253,7 @@ public IQueryNode DisjQuery(string field)
{
{ if (true) return first; }
}
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public IQueryNode ConjQuery(string field)
Expand Down Expand Up @@ -291,7 +291,7 @@ public IQueryNode ConjQuery(string field)
{
{ if (true) return first; }
}
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

// QueryNode Query(CharSequence field) :
Expand Down Expand Up @@ -343,7 +343,7 @@ public IQueryNode ModClause(string field)
q = new ModifierQueryNode(q, mods);
}
{ if (true) return q; }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public IQueryNode Clause(string field)
Expand Down Expand Up @@ -461,7 +461,7 @@ public IQueryNode Clause(string field)
"*", term.BeginColumn, term.EndColumn);
break;
default:
{ if (true) throw new Exception("Unhandled case: operator=" + @operator.ToString()); }
{ if (true) throw Error.Create("Unhandled case: operator=" + @operator.ToString()); }
}
q = new TermRangeQueryNode(qLower, qUpper, lowerInclusive, upperInclusive);
break;
Expand Down Expand Up @@ -563,7 +563,7 @@ public IQueryNode Clause(string field)
}
if (group) { q = new GroupQueryNode(q); }
{ if (true) return q; }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public IQueryNode Term(string field)
Expand Down Expand Up @@ -809,7 +809,7 @@ public IQueryNode Term(string field)
}
}
{ if (true) return q; }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

private bool Jj_2_1(int xla)
Expand Down
24 changes: 12 additions & 12 deletions src/Lucene.Net.QueryParser/Surround/Parser/QueryParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public SrndQuery TopSrndQuery()
q = FieldsQuery();
Jj_consume_token(0);
{ if (true) return q; }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public SrndQuery FieldsQuery()
Expand All @@ -205,7 +205,7 @@ public SrndQuery FieldsQuery()
fieldNames = OptionalFields();
q = OrQuery();
{ if (true) return (fieldNames == null) ? q : GetFieldsQuery(q, fieldNames); }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public IList<string> OptionalFields()
Expand Down Expand Up @@ -234,7 +234,7 @@ public IList<string> OptionalFields()
}
label_1:
{ if (true) return fieldNames; }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public SrndQuery OrQuery()
Expand Down Expand Up @@ -267,7 +267,7 @@ public SrndQuery OrQuery()
}
label_2:
{ if (true) return (queries == null) ? q : GetOrQuery(queries, true /* infix */, oprt); }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public SrndQuery AndQuery()
Expand Down Expand Up @@ -300,7 +300,7 @@ public SrndQuery AndQuery()
}
label_3:
{ if (true) return (queries == null) ? q : GetAndQuery(queries, true /* infix */, oprt); }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public SrndQuery NotQuery()
Expand Down Expand Up @@ -333,7 +333,7 @@ public SrndQuery NotQuery()
}
label_4:
{ if (true) return (queries == null) ? q : GetNotQuery(queries, oprt); }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public SrndQuery NQuery()
Expand Down Expand Up @@ -364,7 +364,7 @@ public SrndQuery NQuery()
}
label_5:
{ if (true) return q; }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public SrndQuery WQuery()
Expand Down Expand Up @@ -395,7 +395,7 @@ public SrndQuery WQuery()
}
label_6:
{ if (true) return q; }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public SrndQuery PrimaryQuery()
Expand Down Expand Up @@ -429,7 +429,7 @@ public SrndQuery PrimaryQuery()
}
OptionalWeights(q);
{ if (true) return q; }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public SrndQuery PrefixOperatorQuery()
Expand Down Expand Up @@ -467,7 +467,7 @@ public SrndQuery PrefixOperatorQuery()
Jj_consume_token(-1);
throw new ParseException();
}
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public IList<SrndQuery> FieldsQueryList()
Expand Down Expand Up @@ -496,7 +496,7 @@ public IList<SrndQuery> FieldsQueryList()
label_7:
Jj_consume_token(RegexpToken.RPAREN);
{ if (true) return queries; }
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public SrndQuery SimpleTerm()
Expand Down Expand Up @@ -544,7 +544,7 @@ public SrndQuery SimpleTerm()
Jj_consume_token(-1);
throw new ParseException();
}
throw new Exception("Missing return statement in function");
throw Error.Create("Missing return statement in function");
}

public void OptionalWeights(SrndQuery q)
Expand Down
Loading

0 comments on commit 0257003

Please sign in to comment.