פרויקט שיצא לproduction בלי Error Handling נכון לא נשאר בproduction זמן רב. הסיפור הנפוץ: מישהו חוזר על call ל-API שנכשל, עוטף ב-try/catch עם catch(e) {} ריק, הbug "נעלם", ואחר כך הלקוח מתקשר לתמיכה שהdashboard שלו מציג נתונים ישנים מאז אתמול בלי שום הסבר. Error handling רע לא עוצר bugs - הוא מסתיר אותם.
בישראל, כמעט בכל ראיון junior שמדגים קוד, המראיין בודק אם יש error handling. fetch בלי .catch, JSON.parse בלי try/catch, אסינכרוני בלי טיפול בשגיאות - כולם red flags שמספרים שמפתח לא ראה production.
Should I catch this error here?
Can I recover meaningfully (retry, fallback, default value)?
כן→ catch & handle
לא→ next
Do I need to add context before re-throwing?
כן→ catch, wrap, throw
לא→ next
Is there a higher layer better positioned to decide?
כן→ let it bubble up
לא→ next
Is this the top of the request / event handler?
כן→ catch, log, return user-friendly error
לא→ let it bubble up