Skip to content

Commit

Permalink
Report all internal errors with consistent error number
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMpn committed May 4, 2024
1 parent 9be3726 commit 52b6ac4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions MarkMpn.Sql4Cds.Engine/Ado/Sql4CdsError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ internal static Sql4CdsError Create(int number, TSqlFragment fragment, params ob
return new Sql4CdsError(template.Class, template.Number, (string)ExpressionFunctions.FormatMessage(template.Message, null, values.Select(v => Collation.USEnglish.ToSqlString(v.ToString())).Cast<INullable>().ToArray()), fragment);
}

internal static Sql4CdsError InternalError(string message, TSqlFragment fragment = null)
{
return new Sql4CdsError(16, 10337, message, fragment);
}

internal static Sql4CdsError NotSupported(TSqlFragment fragment, string clause)
{
return Create(40517, fragment, (SqlInt32)clause.Length, Collation.USEnglish.ToSqlString(clause));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public QueryExecutionException(string message, Exception innerException) : base(
else if (innerEx is FaultException<OrganizationServiceFault> innerFaultEx)
errors.Add(new Sql4CdsError(16, FaultCodeToSqlError(innerFaultEx.Detail), innerFaultEx.Message));
else
errors.Add(new Sql4CdsError(16, 10337, innerEx.Message));
errors.Add(Sql4CdsError.InternalError(innerEx.Message));
}

Errors = errors;
}
else
{
Errors = new[] { new Sql4CdsError(16, 10337, message) };
Errors = new[] { Sql4CdsError.InternalError(message) };
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public NotSupportedQueryFragmentException(string message, TSqlFragment fragment)
public NotSupportedQueryFragmentException(string message, TSqlFragment fragment, Exception innerException) : base(message, innerException)
{
Fragment = fragment;
Errors = new[] { Sql4CdsError.InternalError(message, fragment) };
}

/// <summary>
Expand Down

0 comments on commit 52b6ac4

Please sign in to comment.