{"record":{"id":"9ed1b49f6abcabb1","repo":"Uahh/ToastFish","slug":"pushwords","errorCode":null,"errorMessage":"卡题出错！","messagePattern":"卡题出错！","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"Model/PushControl/PushWords.cs","lineNumber":512,"sourceCode":"            Query.SelectWordList(); //import database\n            Query.GenerateRandomNewCardList(WordList.Number, out List<Card> NewCardLst);\n            Query.GetOverdueReviewedCardList(2 * WordList.Number, out List<Card> ReviewedCardLst);\n            //NewCardLst.Count;\n            //ReviewedCardLst.Count;\n            List<Card> LearningCardLst = new List<Card>();\n            List<Card> FinishedCardLst = new List<Card>();\n\n            double Score;\n            // New Card First\n            Debug.WriteLine($\"开始背单词 @{DateTime.Now}\");\n            while (NewCardLst.Count != 0)\n            {\n                Card newCardi = NewCardLst[0];\n                // Cardstatus cardstatus, int numNewCards, int numLearingCards, int numReviewedCards)\n                Score = pushWords.pushCard(newCardi, newCardi.status, NewCardLst.Count, LearningCardLst.Count, ReviewedCardLst.Count);\n                if (Score == -1)\n                {\n                    MessageBox.Show(\"卡题出错！\");\n                    return;\n                }\n                NewCardLst.RemoveAt(0);\n                newCardi.updateCard(Score);\n                if (newCardi.status != Cardstatus.Reviewed)\n                {\n                    LearningCardLst.Add(newCardi);\n                }\n                else\n                {\n                    FinishedCardLst.Add(newCardi);\n                }\n                LearningCardLst.Sort((a, b) =>\n                {\n                    // compare a to b to get ascending order\n                    int result = a.dateLearingDue.CompareTo(b.dateLearingDue);\n                    return result;\n                });","sourceCodeStart":494,"sourceCodeEnd":530,"githubUrl":"https://github.com/Uahh/ToastFish/blob/2508784a6650862a60e1f3ec3a54dd83efdec98b/Model/PushControl/PushWords.cs#L494-L530","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure Windows notifications for ToastFish are enabled and Focus Assist is off","Click one of the answer buttons on the toast rather than dismissing it","Re-run the recitation; the error is usually transient per-card","Restart the app if toast activation is persistently broken (stale notification registration)"],"exampleFix":"// before\nScore = pushWords.pushCard(newCardi, newCardi.status, ...);\nif (Score == -1) { MessageBox.Show(\"卡题出错！\"); return; }\n// after\nScore = pushWords.pushCard(newCardi, newCardi.status, ...);\nif (Score == -1)\n{\n    MessageBox.Show(\"未能获取答题结果：请检查系统通知设置后重试本题。\");\n    continue; // skip this card instead of aborting the session\n}","handlingStrategy":"try-catch","validationCode":"// before starting recitation\nif (!WindowsToastNotificationsAreEnabled())\n    MessageBox.Show(\"请先在系统设置中允许 ToastFish 发送通知\");","typeGuard":"null","tryCatchPattern":"var score = pushWords.pushCard(card, card.status, ...);\nif (score == -1)\n{\n    Debug.WriteLine(\"未捕获到toast答题结果\");\n    continue; // skip card, keep session alive\n}","preventionTips":["Enable notifications for the app and disable Focus Assist before study sessions","Answer the toast within its on-screen timeout","Avoid dismissing toasts from notification center without answering","Log the inner exception in pushCard instead of returning -1 silently"],"tags":["csharp","sm2","notification","recitation","ui"],"backgroundTag":"unexpected-response-shape","analyzedSha":"2508784a6650862a60e1f3ec3a54dd83efdec98b","analyzedAt":"2026-09-15T23:21:32.897Z","contentChangedAt":"2026-09-15T23:21:32.897Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}