CatchBlock
CatchBlock is a construct used in exception handling to define code that should run when an exception is thrown from a protected region, typically a try block. A catch block specifies the type of exception it can handle and contains statements to respond to the error, which may include logging, cleanup, user messages, or recovery.
When an exception is thrown, control transfers to the first catch block whose type matches the exception.
Across languages the exact syntax differs. In Java: try { ... } catch (IOException ex) { ... }. In C#: try { ... }
Common considerations include ordering catch blocks from most specific to most general, avoiding catching generic exceptions