Improve error messages for unsupported Python objects in user-facing APIs (#9607)
Syntax Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
API Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
API Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
* Improve error message when consolidator period Python object is unsupported * Make unsupported consolidator period error message more concise * Apply descriptive Python conversion errors to other user-facing sites and add QuoteBarConsolidator.FromResolution * List available overloads in unsupported Python argument error messages * Update QuantConnect.pythonnet to 2.0.61 * Update overload hint test expectations to Python-typed signatures * Exclude PyObject overloads from error hints and update to Python annotation style * Move PyObject overload filtering from consumers into MethodSignatureFormatter * Update Python alpha model name expectations for Python-style enum rendering
This commit is contained in:
@@ -1375,7 +1375,18 @@ namespace QuantConnect.Algorithm
|
||||
SetBenchmark(pyBenchmark);
|
||||
return;
|
||||
}
|
||||
SetBenchmark((Symbol)benchmark.AsManagedObject(typeof(Symbol)));
|
||||
|
||||
try
|
||||
{
|
||||
SetBenchmark((Symbol)benchmark.AsManagedObject(typeof(Symbol)));
|
||||
}
|
||||
catch (InvalidCastException exception)
|
||||
{
|
||||
throw new ArgumentException(
|
||||
$"Unable to set the benchmark from {benchmark.ToDisplayString()}: it is not a supported benchmark type. " +
|
||||
MethodSignatureFormatter.FormatOverloads(typeof(QCAlgorithm).GetMethods().Where(m => m.Name == nameof(SetBenchmark))),
|
||||
exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user