Exception là gốc của toàn bộ cây:
Exception
├── StandardError ← rescue bắt ở đây mặc định
│ ├── RuntimeError ← raise không có class → RuntimeError
│ ├── ArgumentError
│ ├── TypeError
│ ├── NoMethodError
│ ├── ZeroDivisionError
│ └── ...
├── SystemExit ← exit() / at_exit
├── Interrupt ← Ctrl+C / SIGINT
└── NoMemoryError ← hết RAMTại sao không rescue Exception: nó bắt cả SystemExit và Interrupt — Ctrl+C bị nuốt, process không tắt được.
Luôn dùng rescue StandardError (hoặc subclass cụ thể).
Exception is the root of the entire tree:
Exception
├── StandardError ← default rescue catches here
│ ├── RuntimeError ← bare raise → RuntimeError
│ ├── ArgumentError
│ ├── TypeError
│ ├── NoMethodError
│ ├── ZeroDivisionError
│ └── ...
├── SystemExit ← exit() / at_exit
├── Interrupt ← Ctrl+C / SIGINT
└── NoMemoryError ← out of RAMWhy not rescue Exception: it catches SystemExit and Interrupt — Ctrl+C gets swallowed and the process can't be stopped.
Always use rescue StandardError (or a specific subclass).