Skip to content

Runtime Error

Easy — everyone uses thisGeneral Dev

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."

Made with passive-aggressive love by manoga.digital. Powered by Claude.