Error
ELI5 — The Vibe Check
An error is when your program says 'I cannot do that' and either stops or complains loudly. It is the computer's way of telling you something went wrong. Errors come in flavors: syntax errors (you misspelled something), runtime errors (it broke while running), and logic errors (it ran but did the wrong thing).
Real Talk
An error is any condition that causes a program to behave unexpectedly or halt. In most languages, errors are objects/values with a type, message, and stack trace. Errors can be caught and handled (try/catch) or left to propagate up the call stack. Unhandled errors in Node.js terminate the process; in browsers they log to the console.
Show Me The Code
// Different types of errors:
// SyntaxError — caught before running:
// const x = { // Missing closing bracket
// TypeError — at runtime:
const user = null;
user.name; // TypeError: Cannot read properties of null
// Custom Error:
throw new Error("User not found");
When You'll Hear This
"What error are you getting?" / "Always read the full error message — it tells you what and where."
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.
Runtime Error
A runtime error is one that only shows up when your program is actually running, not before.
Syntax Error
A syntax error is when you write code that the computer cannot even understand — like handing someone a sentence with no verbs.
Try/Catch
Try/catch is your safety net. You put risky code in the 'try' box, and if it blows up, the 'catch' box catches the explosion and handles it gracefully inst...