babalae/better-genshin-impact · error · NotifierException

Error sending MeoW message: {ex.Message}

Error message

Error sending MeoW message: {ex.Message}

What it means

Catch-all wrapper: any exception escaping SendAsync's try block that is NOT a NotifierException is re-thrown as a NotifierException with its Message. This catches transport-level faults (DNS failure, socket reset, TaskCanceledException, HttpRequestException, JSON errors in BuildContent) that occur before/around the HTTP call.

Source

Thrown at BetterGenshinImpact/Service/Notifier/MeowNotifier.cs:55

        }

        try
        {
            var url = BuildUrl();
            using var response = await _httpClient.PostAsync(url, BuildContent(content));

            if (!response.IsSuccessStatusCode)
            {
                throw new NotifierException($"MeoW 调用失败,状态码: {response.StatusCode}");
            }
        }
        catch (NotifierException)
        {
            throw;
        }
        catch (System.Exception ex)
        {
            throw new NotifierException($"Error sending MeoW message: {ex.Message}");
        }
    }

    private string BuildUrl()
    {
        var url = $"https://api.chuckfang.com/{Uri.EscapeDataString(_nickname)}";
        if (!string.IsNullOrEmpty(_title))
        {
            url += $"/{Uri.EscapeDataString(_title)}";
        }
        return url;
    }

    private StringContent BuildContent(BaseNotificationData notificationData)
    {
        var body = new
        {
            title = $"BetterGI·更好的原神",

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Distinguish the inner exception type in the message (HttpRequestException vs TaskCanceledException) to mirror the Telegram notifier pattern.
  2. Inspect the original ex (consider preserving it as InnerException) to tell DNS/timeout/refused apart.
  3. Add retry-with-backoff for transient IOException/HttpRequestException before propagating.
  4. Confirm network connectivity and that api.chuckfang.com is reachable from the host.

Example fix

// before
catch (System.Exception ex)
{
    throw new NotifierException($"Error sending MeoW message: {ex.Message}");
}

// after
catch (HttpRequestException ex)
{
    throw new NotifierException($"MeoW network error: {ex.Message}", ex);
}
catch (TaskCanceledException)
{
    throw new NotifierException("MeoW request timed out.");
}
catch (System.Exception ex)
{
    throw new NotifierException($"Error sending MeoW message: {ex.Message}", ex);
}
Defensive patterns

Strategy: try-catch

Try / catch

try { await meowNotifier.SendAsync(data); }
catch (NotifierException ex) when (ex.Message.StartsWith("Error sending MeoW"))
{ /* network/transport — log and optionally retry once */ }

Prevention

When it happens

Trigger: DNS resolution for api.chuckfang.com fails; connection refused/reset; the HttpClient is disposed mid-call; JsonSerializer.Serialize throws inside BuildContent; Uri.EscapeDataString on a null would actually be caught earlier — here it is mainly network/IO faults.

Common situations: No internet connection; corporate firewall blocks the host; HttpClient timeout; transient network blip during a scheduled notification.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/2e5a3340a67da4de. Report an issue: GitHub.