Skip to content

Commit

Permalink
Bugfix for "JsonException: '<' is an invalid start of a value
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesbarbez committed Sep 3, 2021
1 parent a7623a7 commit 995859f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion BarbezDotEu.StockTwits.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Product>BarbezDotEu.StockTwits</Product>
<PackageId>BarbezDotEu.StockTwits</PackageId>
<Copyright>©2021 Hannes Barbez</Copyright>
<Version>1.0.2</Version>
<Version>1.0.3-beta</Version>
<Description>An unofficial, modern, very much work-in-progress client for StockTwits APIs.</Description>
<PackageTags>basic;polite;StockTwits;integration;third-party integration;provider;barbez</PackageTags>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
12 changes: 11 additions & 1 deletion StockTwitsDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,17 @@ public async Task<PoliteReponse<StockTwitsResponse>> GetRecentTwitsResponse(stri
var queryUrl = $"{this.Configuration.SearchRecentTwitsUrl}{symbol.ToUpperInvariant()}{this.Configuration.SearchRecentTwitsFields}";
var request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
request.Headers.Accept.Add(acceptHeader);
return await this.Request<StockTwitsResponse>(request, retryOnError, waitingMinutesBeforeRetry);
try
{
var result = await this.Request<StockTwitsResponse>(request, retryOnError, waitingMinutesBeforeRetry);
return result;
}
catch (JsonException e)
{
// TODO: Move try/catch to BarbezDotEu.Provider instead.
base.Logger.LogWarning($"An error occurred that we're going to ignore since occasionally, StockTwits sends back XML/HTML responses. Moving on from: {e}");
return null;
}
}

/// <summary>
Expand Down

0 comments on commit 995859f

Please sign in to comment.