Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

try/catch

Code that says "try this, and if that kind of failure happens, do this instead".

A try statement runs a block; its catch clauses handle exceptions of matching types thrown inside it, and its optional finally block runs however the try block exits.

Examples

  • try { qty = int.Parse(text); } catch (FormatException) { qty = 0; } falls back to 0 when the text isn't a number.

Read the full section →