Catch error with bitflyer

This commit is contained in:
nicolas.dorier 2020-03-26 01:21:16 +09:00
parent c633402fe2
commit 5565d8dae5
No known key found for this signature in database
GPG Key ID: 6618763EF09186FE

View File

@ -21,6 +21,10 @@ namespace BTCPayServer.Services.Rates
{
var response = await _httpClient.GetAsync("https://api.bitflyer.jp/v1/ticker", cancellationToken);
var jobj = await response.Content.ReadAsAsync<JObject>(cancellationToken);
if (jobj.Property("error_message")?.Value?.Value<string>() is string err)
{
throw new Exception($"Error from bitflyer: {err}");
}
var bid = jobj.Property("best_bid").Value.Value<decimal>();
var ask = jobj.Property("best_ask").Value.Value<decimal>();
var rates = new PairRate[1];