JavaScript Errors and Debugging
Read errors, handle failure and debug like a professional.
Every program fails sometimes; professionals are the ones who can tell why. You will classify syntax, runtime, semantic and logic errors, match SyntaxError, ReferenceError, TypeError and RangeError to their causes, and read a stack trace to find where a bad value was made rather than where it crashed. Then you will handle failure with try, catch and finally, rethrow what you cannot handle, throw errors with useful messages, write custom error classes with a cause, and collect every validation problem at once. Finally you will debug by method with console.table, console.group, console.assert, timing, breakpoints and stepping, and put it all together in a settings parser, a safe JSON loader, an order validator and a retry helper. The course calls out each place JavaScript differs from Python's exceptions.
What you will learn
- Classifying errors
- Reading stack traces
- try, catch and finally
- Throwing and custom errors
- Console debugging
- DevTools breakpoints and stepping
- A debugging method
Lessons
- 1
Kinds of Errors
Tell syntax, runtime, semantic and logic errors apart, match SyntaxError, ReferenceError, TypeError and RangeError to their causes, and read a stack trace.
12 exercises
- 2
try, catch and finally
Catch an error and inspect its name, message and stack, handle only what you can and rethrow the rest, clean up with finally, and await what try should protect.
12 exercises
- 3
Throwing and Custom Errors
Throw Error objects with messages that name the bad value, pick TypeError or RangeError, write a custom error class, wrap a low-level error with cause, and report every problem at once.
12 exercises
- 4
Debugging Techniques
Debug with console.error, table, group and assert, measure time, pause with breakpoints and step through code in DevTools, and follow a method: reproduce, isolate, hypothesize, verify.
12 exercises
- 5
Putting It Together
Build the tools every app needs: a safe JSON loader, a settings parser that reports every bad field, an order validator with custom errors, and retry helpers for flaky operations.
8 exercises
How you practice
You practice in the browser and every exercise gives you feedback right away. This course uses these formats:
- Code exercise: 17
- Fix the bug: 14
- Predict the output: 8
- Type the answer: 5
- Multiple choice: 4
- Match the pairs: 3
- Fill in the blank: 3
- Spot the bug: 1
- Reorder lines: 1
Aligned to
- Software Development Fundamentals
- SDF-FundamentalsFundamental Programming Concepts and Practices
- SDF-PracticesSoftware Development Practices
- Basics of JavaScript and Computer Programming
- 1.2.1Set up the programming environment
- Errors, Exceptions, Debugging
- 6.1.1Recognize syntax, semantic, logic and runtime errors
- 6.2.1Recognize SyntaxError, ReferenceError, TypeError and RangeError
- 6.3.1Handle exceptions with try, catch, finally and throw
- 6.4.1Debug code and measure execution time
- JavaScript fundamentals
- 6.15Debugging JavaScript and handling errors
Proto Node Labs is not affiliated with or endorsed by ACM / IEEE-CS / AAAI, JS Institute and Mozilla. Exam names are trademarks of their owners.