fix: apply PR review feedback corrections

Addresses valid Copilot AI review comments from PR #152:

1.  Add 'Failed to decrypt' check to console.error handler
   - Fixes inconsistency between console.log and console.error
   - Both handlers now detect all error types uniformly

2.  Fix double space in emoji error messages
   - Changed '⚠️  Session Error' to '⚠️ Session Error'
   - Consistent with other emoji messages (one space)

3.  Add type safety to args[1] concatenation
   - Changed (args[1] || '') to String(args[1] ?? '')
   - Prevents "[object Object]" when args[1] is an object

https://claude.ai/code/session_01TvSrN9JmHZDdKMZDFWEcUS
This commit is contained in:
Claude
2026-02-12 18:57:48 +00:00
parent aca49891e5
commit 6c6f49d93f
+6 -4
View File
@@ -30,7 +30,7 @@ console.log = function(...args: unknown[]) {
msg.includes('Failed to decrypt')
) {
// Extract error type
let errorType = '⚠️ Session Error'
let errorType = '⚠️ Session Error'
if (msg.includes('Bad MAC')) errorType = '🔐 Bad MAC Error'
else if (msg.includes('MessageCounterError') || msg.includes('Key used already')) errorType = '🔢 Counter Error'
else if (msg.includes('Failed to decrypt')) errorType = '🔌 Decryption Failed'
@@ -74,15 +74,17 @@ console.error = function(...args: unknown[]) {
msg.includes('Session error') ||
msg.includes('Bad MAC') ||
msg.includes('MessageCounterError') ||
msg.includes('Key used already')
msg.includes('Key used already') ||
msg.includes('Failed to decrypt')
) {
// Extract error type
let errorType = '⚠️ Session Error'
let errorType = '⚠️ Session Error'
if (msg.includes('Bad MAC')) errorType = '🔐 Bad MAC Error'
else if (msg.includes('MessageCounterError') || msg.includes('Key used already')) errorType = '🔢 Counter Error'
else if (msg.includes('Failed to decrypt')) errorType = '🔌 Decryption Failed'
// Extract JID from stack trace or message
const jidMatch = (msg + (args[1] || '')).match(/(\d{10,}(?:_\d+\.\d+)?)/);
const jidMatch = (msg + String(args[1] ?? '')).match(/(\d{10,}(?:_\d+\.\d+)?)/);
const jid = jidMatch ? jidMatch[1] : null
const maskedJid = jid && jid.length > 8 ? `${jid.substring(0, 4)}****${jid.substring(jid.length - 4)}` : jid