Error Handling

Errors don't
scare us.

try / catch finally async errors custom throw console methods
Module 01
Form Validator
Classic try / catch pattern. Each field throws a custom error with a clear message when validation fails.
Module 02
Division Machine
JavaScript returns Infinity for division by zero — not an error. We use throw to enforce our own rules.
What's happening

We manually throw new Error() to create a custom error with a meaningful message instead of silently returning a bad value.

Module 03
Async Error Catcher
try / catch with async/await. A 404 does not throw automatically — you must check response.ok.
1
Sending request
2
Checking response status
3
Parsing JSON
Module 04
The Finally Block
finally always runs — whether the try succeeded or catch triggered. Use it for cleanup.
Why finally matters

Think of it as a door that always closes behind you — pass or fail. Use it to clear inputs, reset loaders, and write audit logs.

Output Console
// Interact with any module above to see output here.