Right now Searchlight uses exceptions to indicate that parsing failed. It might be better instead to produce a list of validation results, so that if more than one error could be determined at a time we could use that rather than the exception system.
Today, the code looks like this:
try {
var request = new FetchRequest() { ... };
var syntax = engine.Parse(request);
var sql = syntax.ToSqlServerCommand(true);
} catch (e) { ... }
However, some programmers may not want to use exceptions. Why don't we also support a Validate() or TryParse() method? Then, the code could look like this:
var request = new FetchRequest() { ... };
if (!engine.Validate(request, out errors)) {
Console.WriteLine(errors.ToString());
}
if (engine.TryParse(request, out syntax)) {
// Execute the syntax
}
Right now Searchlight uses exceptions to indicate that parsing failed. It might be better instead to produce a list of validation results, so that if more than one error could be determined at a time we could use that rather than the exception system.
Today, the code looks like this:
However, some programmers may not want to use exceptions. Why don't we also support a
Validate()orTryParse()method? Then, the code could look like this: