Uahh/ToastFish · error

卡题出错!

Error message

卡题出错!

What it means

In RecitationSM2, when a new card is pushed via pushCard and it returns -1, the app shows '卡题出错!' and aborts the recitation loop. pushCard returns -1 (its sentinel error value) when the toast-notification answer task throws — typically because the user's answer could not be captured or the notification interaction failed.

Solutions

  1. Ensure Windows notifications for ToastFish are enabled and Focus Assist is off
  2. Click one of the answer buttons on the toast rather than dismissing it
  3. Re-run the recitation; the error is usually transient per-card
  4. Restart the app if toast activation is persistently broken (stale notification registration)

Example fix

// before
Score = pushWords.pushCard(newCardi, newCardi.status, ...);
if (Score == -1) { MessageBox.Show("卡题出错!"); return; }
// after
Score = pushWords.pushCard(newCardi, newCardi.status, ...);
if (Score == -1)
{
    MessageBox.Show("未能获取答题结果:请检查系统通知设置后重试本题。");
    continue; // skip this card instead of aborting the session
}
Defensive patterns

Strategy: try-catch

Validate before calling

// before starting recitation
if (!WindowsToastNotificationsAreEnabled())
    MessageBox.Show("请先在系统设置中允许 ToastFish 发送通知");

Type guard

null

Try / catch

var score = pushWords.pushCard(card, card.status, ...);
if (score == -1)
{
    Debug.WriteLine("未捕获到toast答题结果");
    continue; // skip card, keep session alive
}

Prevention

When it happens

Trigger: pushWords.pushCard(newCardi, ...) on the first card of NewCardLst throws inside ProcessToastNotificationRecitationSM2 (e.g. the toast notification was dismissed, the toast API returned a faulted task, or a UI-thread/notification-permission failure), so Score == -1.

Common situations: Windows notifications disabled/Focus Assist suppressing toasts so no answer ever arrives; user clicking away and dismissing the toast; notification center overflow; running on Windows versions where the toast activation callback fails.

Related errors


AI-assisted analysis of Uahh/ToastFish@2508784a66 (2026-09-15). Data as JSON: /api/errors/9ed1b49f6abcabb1. Report an issue: GitHub.

Appendix: source

Thrown at Model/PushControl/PushWords.cs:512

            Query.SelectWordList(); //import database
            Query.GenerateRandomNewCardList(WordList.Number, out List<Card> NewCardLst);
            Query.GetOverdueReviewedCardList(2 * WordList.Number, out List<Card> ReviewedCardLst);
            //NewCardLst.Count;
            //ReviewedCardLst.Count;
            List<Card> LearningCardLst = new List<Card>();
            List<Card> FinishedCardLst = new List<Card>();

            double Score;
            // New Card First
            Debug.WriteLine($"开始背单词 @{DateTime.Now}");
            while (NewCardLst.Count != 0)
            {
                Card newCardi = NewCardLst[0];
                // Cardstatus cardstatus, int numNewCards, int numLearingCards, int numReviewedCards)
                Score = pushWords.pushCard(newCardi, newCardi.status, NewCardLst.Count, LearningCardLst.Count, ReviewedCardLst.Count);
                if (Score == -1)
                {
                    MessageBox.Show("卡题出错!");
                    return;
                }
                NewCardLst.RemoveAt(0);
                newCardi.updateCard(Score);
                if (newCardi.status != Cardstatus.Reviewed)
                {
                    LearningCardLst.Add(newCardi);
                }
                else
                {
                    FinishedCardLst.Add(newCardi);
                }
                LearningCardLst.Sort((a, b) =>
                {
                    // compare a to b to get ascending order
                    int result = a.dateLearingDue.CompareTo(b.dateLearingDue);
                    return result;
                });

View on GitHub (pinned to 2508784a66)