Runtime Error
ELI5 — The Vibe Check
A runtime error is one that only shows up when your program is actually running, not before. The code looks fine to the computer, it starts running, then boom — it hits something it cannot handle, like trying to open a door that is not there. The classic example: accessing a property on null.
Real Talk
A runtime error occurs during program execution after the code has been successfully parsed and compiled. These errors arise from operations that cannot be performed at runtime — dividing by zero, accessing an undefined property, out-of-bounds array access, or network failures. In dynamically typed languages, many type errors are runtime errors since types are not checked until execution.
Show Me The Code
// This looks fine syntactically but fails at runtime:
const users = null; // maybe from a failed API call
console.log(users.length);
// TypeError: Cannot read properties of null (reading 'length')
// Runtime error from invalid operation:
const result = 10 / 0; // Infinity in JS, crash in some other languages
// Fix: always guard against null:
const users = null;
console.log(users?.length ?? 0); // safe with optional chaining
When You'll Hear This
"It passed linting but threw a runtime error in production." / "Runtime errors are harder to catch because you need to actually run the code."
Related Terms
Bug
A bug is anything in your code that makes it behave wrong.
Exception
An exception is a special kind of error that 'throws' itself up through your code like a hot potato, looking for someone to catch it.
Logic Error
A logic error is the sneakiest kind of bug — the code runs perfectly fine, no crashes, no errors, but it does the WRONG thing.
Null
Null means 'intentionally nothing' — a programmer chose to say 'there is no value here'. It is a deliberate absence.
Syntax Error
A syntax error is when you write code that the computer cannot even understand — like handing someone a sentence with no verbs.