{"record":{"id":"2e5a3340a67da4de","repo":"babalae/better-genshin-impact","slug":"error-sending-meow-message-ex-message","errorCode":null,"errorMessage":"Error sending MeoW message: {ex.Message}","messagePattern":"Error sending MeoW message: (.+?)","errorType":"exception","errorClass":"NotifierException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Service/Notifier/MeowNotifier.cs","lineNumber":55,"sourceCode":"        }\n\n        try\n        {\n            var url = BuildUrl();\n            using var response = await _httpClient.PostAsync(url, BuildContent(content));\n\n            if (!response.IsSuccessStatusCode)\n            {\n                throw new NotifierException($\"MeoW 调用失败，状态码: {response.StatusCode}\");\n            }\n        }\n        catch (NotifierException)\n        {\n            throw;\n        }\n        catch (System.Exception ex)\n        {\n            throw new NotifierException($\"Error sending MeoW message: {ex.Message}\");\n        }\n    }\n\n    private string BuildUrl()\n    {\n        var url = $\"https://api.chuckfang.com/{Uri.EscapeDataString(_nickname)}\";\n        if (!string.IsNullOrEmpty(_title))\n        {\n            url += $\"/{Uri.EscapeDataString(_title)}\";\n        }\n        return url;\n    }\n\n    private StringContent BuildContent(BaseNotificationData notificationData)\n    {\n        var body = new\n        {\n            title = $\"BetterGI·更好的原神\",","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Service/Notifier/MeowNotifier.cs#L37-L73","documentation":"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.","triggerScenarios":"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.","commonSituations":"No internet connection; corporate firewall blocks the host; HttpClient timeout; transient network blip during a scheduled notification.","solutions":["Distinguish the inner exception type in the message (HttpRequestException vs TaskCanceledException) to mirror the Telegram notifier pattern.","Inspect the original ex (consider preserving it as InnerException) to tell DNS/timeout/refused apart.","Add retry-with-backoff for transient IOException/HttpRequestException before propagating.","Confirm network connectivity and that api.chuckfang.com is reachable from the host."],"exampleFix":"// before\ncatch (System.Exception ex)\n{\n    throw new NotifierException($\"Error sending MeoW message: {ex.Message}\");\n}\n\n// after\ncatch (HttpRequestException ex)\n{\n    throw new NotifierException($\"MeoW network error: {ex.Message}\", ex);\n}\ncatch (TaskCanceledException)\n{\n    throw new NotifierException(\"MeoW request timed out.\");\n}\ncatch (System.Exception ex)\n{\n    throw new NotifierException($\"Error sending MeoW message: {ex.Message}\", ex);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await meowNotifier.SendAsync(data); }\ncatch (NotifierException ex) when (ex.Message.StartsWith(\"Error sending MeoW\"))\n{ /* network/transport — log and optionally retry once */ }","preventionTips":["Confirm network connectivity before scheduled notifications.","Preserve the inner exception for stack traces.","Distinguish HttpRequestException from TaskCanceledException for clearer errors."],"tags":["meow","network","catch-all","notifier"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}