Try-Catch

Noun · Development

Definitions

  1. A control-flow construct that executes a block of code (try) and, if an exception is thrown during execution, transfers control to a handler block (catch) matched by exception type, allowing the program to recover or log gracefully instead of crashing.

    In plain English: A way to attempt something risky in code and handle the error gracefully if it goes wrong, instead of letting the program crash.

    Example: "Wrap the JSON.parse call in a try-catch — if someone sends us malformed JSON, we should return a 400, not a 500."

Related Terms