babalae/better-genshin-impact · warning · NotifierException

MeoW 昵称为空

Error message

MeoW 昵称为空

What it means

MeowNotifier.SendAsync rejects an empty/whitespace _nickname (passed to the constructor) before building the request URL, because the nickname is the only required path segment for the chuckfang.com push API. Without it the URL would be malformed, so the notifier fails fast.

Source

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

    private readonly string _title;

    private readonly JsonSerializerOptions _jsonSerializerOptions = new()
    {
        PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
    };

    public MeowNotifier(HttpClient httpClient, string nickname, string title)
    {
        _httpClient = httpClient;
        _nickname = nickname;
        _title = title;
    }

    public async Task SendAsync(BaseNotificationData content)
    {
        if (string.IsNullOrWhiteSpace(_nickname))
        {
            throw new NotifierException("MeoW 昵称为空");
        }

        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)
        {

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Set a non-empty MeoW nickname in the notifier settings UI/config before enabling the channel.
  2. Gate notifier registration so MeowNotifier is only added when nickname is non-whitespace.
  3. Add a settings-page validation hint so the user cannot save an enabled MeoW channel without a nickname.

Example fix

// before
var notifier = new MeowNotifier(httpClient, nickname, title);

// after
if (string.IsNullOrWhiteSpace(nickname))
    throw new InvalidOperationException("MeoW nickname must be configured before constructing MeowNotifier.");
var notifier = new MeowNotifier(httpClient, nickname, title);
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrWhiteSpace(nickname))
    throw new InvalidOperationException("Configure a MeoW nickname before sending.");

Type guard

static bool IsMeowConfigured(string nickname) => !string.IsNullOrWhiteSpace(nickname);

Try / catch

try { await meowNotifier.SendAsync(data); }
catch (NotifierException ex) when (ex.Message.Contains("昵称为空"))
{ /* prompt user to fill nickname, do not retry */ }

Prevention

When it happens

Trigger: MeowNotifier constructed with nickname that is null, empty, or whitespace-only; SendAsync's IsNullOrWhiteSpace(_nickname) guard at line 34 fires.

Common situations: Settings migration left the MeoW nickname field blank; user enabled the MeoW notifier but never filled the nickname; a default-empty binding wired the textbox to the constructor.

Related errors


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