mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
Improve error handling
This commit is contained in:
parent
b29c3cb995
commit
a1a95417f0
@ -103,10 +103,16 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
|
||||
});
|
||||
var result = _client.PostAsync("/v2/translate", postContent).Result;
|
||||
var resultContent = result.Content.ReadAsStringAsync().Result;
|
||||
|
||||
if (!result.IsSuccessStatusCode)
|
||||
{
|
||||
SeLogger.Error("DeepLTranslate error: " + resultContent);
|
||||
}
|
||||
|
||||
if (result.StatusCode == HttpStatusCode.Forbidden)
|
||||
{
|
||||
Error = resultContent;
|
||||
throw new Exception("Bad API key");
|
||||
throw new Exception("Forbidden! " + Environment.NewLine + Environment.NewLine + resultContent);
|
||||
}
|
||||
|
||||
var resultList = new List<string>();
|
||||
|
Loading…
Reference in New Issue
Block a user