# Exception

> A signal that something broke mid-run. Code can catch it so the app does not crash.

**Field:** Software Development  
**Category:** Programming Concepts  
**Also known as:** Exception Handling, Try Catch, try/except

## Think of it like

Think of it like a net under a high rope. If the walker slips, the net catches them.

## Definition

An exception is a signal a program sends when something fails mid-run. If nothing catches it, the program stops. Code can wrap risky lines in a try block and catch the exception in an except or catch block. There it can show a kind message, try again or use a default. Exceptions let a program fail gently instead of crashing.

## Example

A sign-up form tries int(age). When Jack types twelve, the form catches the ValueError and asks for a number.

## Example code

```python
try:
    age = int("twelve")
except ValueError:
    print("Please type a number")
# prints: Please type a number
```

The bad input is caught, so the program asks again instead of crashing.

## Why it matters

Real input is messy and networks fail. Catching exceptions keeps one bad case from taking the whole app down.

## Common mistake

Catching every exception and doing nothing. The bug is hidden, not fixed, and it comes back later.

## Three principles

- **Raised on trouble.** Something failed while the code ran.
- **Catch what you expect.** Name the kind of error you can handle.
- **Never hide it.** Log it or tell the user.

## Related terms

- [Runtime Error](https://learn.benibix.com/term/development/runtime-error)
- [Error](https://learn.benibix.com/term/development/error)
- [Stack Trace](https://learn.benibix.com/term/development/stack-trace)
- [Input and Output](https://learn.benibix.com/term/development/input-output)

## Taught in

- [Exceptions and Debugging](https://learn.benibix.com/learn/development-concepts/exceptions-and-debugging): Programming Basics, 16/18

---

Source: https://learn.benibix.com/term/development/exception
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
