Skip to content

PRO TIP Block youtube.com at the DNS level — Pi-hole, NextDNS or your hosts file — but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

Javascript Error Handling | Handle Errors in Javascript | Try Catch Finally

27.2K views on YouTube

Web Dev Roadmap for Beginners (Free!): https://bit.ly/DaveGrayWebDevRoadmap

In this video we’ll review Javascript Error Handling with Try, Catch, and Finally. We’ll also look at JavaScript Error Constructor Types, console error messages, and how to create custom error constructors and messages.

▶ This video is part of the JavaScript Tutorials for Beginners Playlist found here: https://www.youtube.com/playlist?list=PL0Zuz27SZ-6Oi6xNtL_fwCrwpuqylMsgT

✅ Quick Concepts outline:
Javascript Errors and Error Handling:
(00:00) Intro
(0:13) Strict Mode
(1:20) Common JavaScript Error Types
(1:30) ReferenceError
(2:00) SyntaxError
(3:00) TypeError
(3:50) Using a Try Catch block
(4:15) The catchID parameter
(5:10) Using console.error() instead of console.log()
(5:40) console.warn()
(6:00) console.table()
(6:20) Error Object properties: name, message, stack
(7:20) Create a Custom Error
(8:20) throw keyword
(9:20) The generic error constructor
(10:20) Adding a finally to your Try Catch block
(10:45) An example of Try, Catch, Finally

📚 Further Reading:
MDN Web Docs:
Error Constructor Types: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
Error Handling: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Control_flow_and_error_handling
Try…Catch: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try…catch
Eloquent JavaScript Chapter 8:
https://eloquentjavascript.net/08_error.html

📺 More Beginner JS Videos:
freeCodeCamp: https://youtu.be/PkZNo7MFNFg
Traversy Media: https://youtu.be/hdI2bqOjy3c
The Net Ninja: https://youtu.be/iWOYAxlnaww

✅ Follow Me:
Twitter: https://twitter.com/yesdavidgray
Reddit: https://www.reddit.com/user/DaveOnEleven
Medium: https://medium.com/@davegray_86804

#javascript #error #handling