mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
Improve error handling
This commit is contained in:
parent
d42a974457
commit
7d56cf185f
@ -141,6 +141,12 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
|
||||
.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
httpClient.DefaultRequestHeaders.TryAddWithoutValidation(SecurityHeaderName, apiKey);
|
||||
var response = httpClient.PostAsync(tokenEndpoint, new StringContent(string.Empty)).Result;
|
||||
var result = response.Content.ReadAsStringAsync().Result;
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
SeLogger.Error($"{StaticName}: Error getting access token via {tokenEndpoint} and API key {apiKey}: {result}");
|
||||
}
|
||||
|
||||
return response.Content.ReadAsStringAsync().Result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user