IvanovAndrew / AmdConverterTelegramBot

1 stars 0 forks source link

Improve sustainability of parsers #12

Open IvanovAndrew opened 1 year ago

IvanovAndrew commented 1 year ago

MIR site is unavailable sometimes. It leads to this error

System.NullReferenceException: Object reference not set to an instance of an object.
         at AmdConverterTelegramBot.Services.MirSiteParser.Parse(HtmlDocument htmlDocument) in C:\Users\warrior_spb\RiderProjects\AmdConverterTelegramBot\AmdConverterTelegramBot\Services\MirSiteParser.cs:line 24
         at AmdConverterTelegramBot.Services.MirSiteParser.Parse(String html) in C:\Users\warrior_spb\RiderProjects\AmdConverterTelegramBot\AmdConverterTelegramBot\Services\MirSiteParser.cs:line 19
         at AmdConverterTelegramBot.Services.RateLoader.LoadNonCashRates() in C:\Users\warrior_spb\RiderProjects\AmdConverterTelegramBot\AmdConverterTelegramBot\Services\RateLoader.cs:line 78
         at AmdConverterTelegramBot.Controllers.AmdConverterController.Post(Update update) in C:\Users\warrior_spb\RiderProjects\AmdConverterTelegramBot\AmdConverterTelegramBot\Controllers\AmdConverterController.cs:line 173
IvanovAndrew commented 1 year ago

The same is actual for Rate.am. In this case bot should take info from bank sites directly

System.NullReferenceException: Object reference not set to an instance of an object.
         at AmdConverterTelegramBot.Services.RateAmParser.Parse(HtmlDocument webPage) in C:\Users\warrior_spb\RiderProjects\AmdConverterTelegramBot\AmdConverterTelegramBot\SiteParser\RateAmParser.cs:line 34
         at AmdConverterTelegramBot.Services.RateAmParser.Parse(String html) in C:\Users\warrior_spb\RiderProjects\AmdConverterTelegramBot\AmdConverterTelegramBot\SiteParser\RateAmParser.cs:line 22
         at AmdConverterTelegramBot.Services.RateLoader.RatesFromRateAm(HttpClient httpClient, Boolean cash) in C:\Users\warrior_spb\RiderProjects\AmdConverterTelegramBot\AmdConverterTelegramBot\Services\RateLoader.cs:line 63
         at AmdConverterTelegramBot.Services.RateLoader.LoadRates(Boolean cash) in C:\Users\warrior_spb\RiderProjects\AmdConverterTelegramBot\AmdConverterTelegramBot\Services\RateLoader.cs:line 32
         at AmdConverterTelegramBot.Controllers.AmdConverterController.Post(Update update) in C:\Users\warrior_spb\RiderProjects\AmdConverterTelegramBot\AmdConverterTelegramBot\Controllers\AmdConverterController.cs:line 175
         at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
         at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
         at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
         at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)