Greenfield: Improve error message, do not use internal lightning node on store's lightning API

This commit is contained in:
nicolas.dorier
2021-12-16 12:32:13 +09:00
parent bbddd72780
commit 4f7eeea14e
12 changed files with 149 additions and 64 deletions

View File

@@ -54,12 +54,12 @@ namespace BTCPayServer.Client
;
throw new GreenFieldValidationException(err);
}
else if (message.StatusCode == System.Net.HttpStatusCode.BadRequest)
else if (!message.IsSuccessStatusCode && message.Content?.Headers?.ContentType?.MediaType?.StartsWith("application/json", StringComparison.OrdinalIgnoreCase) is true)
{
var err = JsonConvert.DeserializeObject<Models.GreenfieldAPIError>(await message.Content.ReadAsStringAsync());
throw new GreenFieldAPIException(err);
if (err.Code != null)
throw new GreenFieldAPIException((int)message.StatusCode, err);
}
message.EnsureSuccessStatusCode();
}