Skip to content

Commit

Permalink
fix: additional validation to enum parsed value
Browse files Browse the repository at this point in the history
  • Loading branch information
Romazes committed Feb 21, 2024
1 parent c06d31a commit f6ee567
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions QuantConnect.IEX/IEXDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,9 @@ private void Initialize(string apiKey, string pricePlan)
{
_apiKey = apiKey;

IEXPricePlan parsedPricePlan;
try
{
parsedPricePlan = Enum.Parse<IEXPricePlan>(pricePlan, true);
}
catch (Exception ex)
if (!Enum.TryParse<IEXPricePlan>(pricePlan, out var parsedPricePlan) || !Enum.IsDefined(typeof(IEXPricePlan), parsedPricePlan))
{
throw new Exception($"An error occurred while parsing the price plan '{pricePlan}'. Please ensure that the provided price plan is valid and supported by the system.", ex);
throw new ArgumentException($"An error occurred while parsing the price plan '{pricePlan}'. Please ensure that the provided price plan is valid and supported by the system.");
}

var (requestPerSecond, maximumClients) = RateLimits[parsedPricePlan];
Expand Down

0 comments on commit f6ee567

Please sign in to comment.