SubtitleEdit/subtitleedit · error · Exception

DeepL failed with status code {(int)result.StatusCode} ({res

Error message

DeepL failed with status code {(int)result.StatusCode} ({result.StatusCode})

 {resultContent}

What it means

Thrown by DeepLTranslate when the response is not success and not 403 (which is handled separately). Covers 4xx errors like 400 Bad Request / 413 Payload Too Large / 456 Quota exceeded, and 5xx server errors after retries failed. The status code, enum name, and response body are all included.

Source

Thrown at src/libuilogic/AutoTranslate/DeepLTranslate.cs:187

                if (!ShouldRetry(result, resultContent) || attempt == retryDelays.Length)
                {
                    break;
                }

                await Task.Delay(retryDelays[attempt], cancellationToken);
            }

            if (result.StatusCode == HttpStatusCode.Forbidden)
            {
                Error = resultContent;
                throw new Exception("Forbidden! " + Environment.NewLine + Environment.NewLine + resultContent);
            }

            if (!result.IsSuccessStatusCode)
            {
                Error = resultContent;
                SeLogger.Error("DeepLTranslate error: " + resultContent);
                throw new Exception($"DeepL failed with status code {(int)result.StatusCode} ({result.StatusCode})" + Environment.NewLine + Environment.NewLine + resultContent);
            }

            try
            {
                var resultList = new List<string>();
                var parser = new JsonParser();
                var x = (Dictionary<string, object>)parser.Parse(resultContent);
                foreach (var k in x.Keys)
                {
                    if (x[k] is List<object> mainList)
                    {
                        foreach (var mainListItem in mainList)
                        {
                            if (mainListItem is Dictionary<string, object> innerDic)
                            {
                                foreach (var transItem in innerDic.Keys)
                                {
                                    if (transItem == "text")

View on GitHub (pinned to 17a9f07487)

Solutions

  1. Read the numeric code: 456 = raise DeepL plan quota; 400 = fix the request (language codes, text length); 5xx = retry later or switch endpoint.
  2. Verify source/target language codes are in DeepLTranslate.GetTranslationPairs (DeepLTranslate.cs:100-150).
  3. Check the DeepL dashboard usage page for quota status.
  4. Inspect the full resultContent in the message for DeepL's own error JSON.

Example fix

// before
SeLogger.Error("DeepLTranslate error: " + resultContent);
throw new Exception($"DeepL failed with status code {(int)result.StatusCode} ({result.StatusCode})" + Environment.NewLine + Environment.NewLine + resultContent);

// after - branch on DeepL's documented 456 quota code so the user sees a clear cause
if ((int)result.StatusCode == 456)
{
    throw new Exception("DeepL quota exceeded (456) - upgrade your plan or wait for the quota reset." + Environment.NewLine + Environment.NewLine + resultContent);
}
throw new Exception($"DeepL failed with status code {(int)result.StatusCode} ({result.StatusCode})" + Environment.NewLine + Environment.NewLine + resultContent);
Defensive patterns

Strategy: retry

Validate before calling

// Validate language codes are in DeepL's supported set before translating
var supported = deeLTranslate.GetSupportedTargetLanguages().Select(p => p.Code).ToHashSet();
if (!supported.Contains(targetLanguageCode))
    throw new ArgumentException($"Target language '{targetLanguageCode}' is not supported by DeepL.");

Try / catch

try
{
    return await deeLTranslate.Translate(text, src, tgt, token);
}
catch (Exception ex) when (ex.Message.Contains("DeepL failed with status code"))
{
    if (ex.Message.Contains("456"))
        throw new InvalidOperationException("DeepL quota exceeded - upgrade the plan.", ex);
    if (ex.Message.Contains("400"))
        throw new InvalidOperationException("DeepL rejected the request - check language codes and payload.", ex);
    throw;
}

Prevention

When it happens

Trigger: Translate() retries on 429/503 only (see ShouldRetry, DeepLTranslate.cs:225-232); any other non-success status breaks out of the loop immediately and lands here. DeepL-specific 456 (quota exceeded) and 400 (malformed request) are common hits.

Common situations: DeepL 456 quota exceeded (monthly character limit hit); 400 from invalid language codes or a request body that exceeds limits; transient 5xx that did not match the retry filter; proxy returning an unexpected status.

Related errors


AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13). Data as JSON: /api/errors/f95ed3598fc6febf. Report an issue: GitHub.