Skip to content

Commit

Permalink
feat: handle "parsing to enum" excpetion
Browse files Browse the repository at this point in the history
  • Loading branch information
Romazes committed Feb 21, 2024
1 parent c323b42 commit c06d31a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion QuantConnect.IEX/IEXDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,18 @@ public void SetJob(LiveNodePacket job)
private void Initialize(string apiKey, string pricePlan)
{
_apiKey = apiKey;
var (requestPerSecond, maximumClients) = RateLimits[Enum.Parse<IEXPricePlan>(pricePlan, true)];

IEXPricePlan parsedPricePlan;
try
{
parsedPricePlan = Enum.Parse<IEXPricePlan>(pricePlan, true);
}
catch (Exception ex)
{
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);
}

var (requestPerSecond, maximumClients) = RateLimits[parsedPricePlan];
_rateGate = new RateGate(requestPerSecond, Time.OneSecond);

_subscriptionManager = new EventBasedDataQueueHandlerSubscriptionManager();
Expand Down

0 comments on commit c06d31a

Please sign in to comment.