babalae/better-genshin-impact · error · NotifierException
Error sending OneBot message: {ex.Message}
Error message
Error sending OneBot message: {ex.Message} What it means
Catch-all wrapper around SendAsync: any non-NotifierException (network, DNS, JSON parse of the OneBot response, ObjectDisposedException on the HttpClient) is re-wrapped as a NotifierException. Note it loses the original exception as InnerException.
Source
Thrown at BetterGenshinImpact/Service/Notifier/OneBotNotifier.cs:92
var groupResponse = await SendMessage(url, content, false);
if (!groupResponse)
{
success = false;
}
}
if (!success)
{
throw new NotifierException("OneBot message sending failed");
}
}
catch (NotifierException)
{
throw;
}
catch (System.Exception ex)
{
throw new NotifierException($"Error sending OneBot message: {ex.Message}");
}
}
private async Task<bool> SendMessage(string url, BaseNotificationData content, bool isPrivate)
{
// 构建消息内容
var messageContent = new List<object>
{
new
{
type = "text",
data = new { text = content.Message }
}
};
// 如果有截图,添加图片消息
if (content.Screenshot != null)
{View on GitHub (pinned to a7cb36712d)
Solutions
- Preserve ex as InnerException for stack-trace diagnosis.
- Separate HttpRequestException (network) from JsonException (bad response) for clearer messages.
- Confirm the OneBot HTTP server is listening on the endpoint host/port and reachable.
- If behind a reverse proxy, ensure it returns JSON, not an HTML error page.
Example fix
// before
catch (System.Exception ex)
{
throw new NotifierException($"Error sending OneBot message: {ex.Message}");
}
// after
catch (HttpRequestException ex)
{
throw new NotifierException($"OneBot network error: {ex.Message}", ex);
}
catch (JsonException ex)
{
throw new NotifierException($"OneBot returned non-JSON response: {ex.Message}", ex);
}
catch (System.Exception ex)
{
throw new NotifierException($"Error sending OneBot message: {ex.Message}", ex);
} Defensive patterns
Strategy: try-catch
Try / catch
try { await oneBotNotifier.SendAsync(data); }
catch (NotifierException ex) when (ex.Message.StartsWith("Error sending OneBot"))
{ /* network/transport or non-JSON response — check OneBot server reachability */ } Prevention
- Confirm the OneBot HTTP server is listening and reachable.
- Ensure any reverse proxy returns JSON, not HTML error pages.
- Preserve inner exceptions for diagnosis.
When it happens
Trigger: HttpClient.SendAsync throws HttpRequestException (DNS/connection refused); JsonDocument.Parse throws JsonException on a non-JSON OneBot error page; the connection is reset.
Common situations: OneBot framework not running on the configured host:port; firewall blocks loopback-to-loopback on a containerized setup; the endpoint returns HTML (reverse proxy error page) so JSON parsing fails.
Related errors
- Error sending MeoW message: {ex.Message}
- Error sending ServerChan message: {ex.Message}
- OneBot endpoint is not set
- OneBot requires either a user ID or group ID
- OneBot message sending failed
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/a3ca572b00231649.
Report an issue: GitHub.