Exception
Pronunciationik-SEP-shun
Definition
An error that happens while the program runs. It stops normal flow unless your code catches and handles it.
Where you hear it
Stack traces, logs, try/catch, and bug reports.
Examples
The service throws an exception when the file is missing.
Catch the exception and show a friendly message.
The loop stops with an exception because the list ran out of items.
Common mistake
Catching every exception and ignoring it. The error disappears from sight but not from reality.
Don't confuse with
An exception represents a runtime error that your code can handle, whereas a syntax error prevents the code from compiling or running at all.
Say it at work
- In a meeting or chat
Make sure to add a specific try-catch block here so we don't let this exception crash the background worker.
- In an email or ticket
Please wrap the database call in a try-catch block and log the exception details for further investigation.
Keep exploring
More in Programming Fundamentals