From the course: Node.js: Debugging and Performance Tuning
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Implementing Express error pages
From the course: Node.js: Debugging and Performance Tuning
Implementing Express error pages
- [Instructor] We're going to use Express' built-in middleware to implement some error pages that log to the console. Then we'll fix that first issue. Why bother to implement error pages? It's a best practice to implement custom error pages in node applications for a couple of reasons. First, there's the control over the user experience. It can be very jarring to get a white page with a little bit of diagnostic information instead of a nicely themed error page. Also, in the case of 404s, some sites have a custom call-to-action that can direct users to actual content destinations. Finally, custom error pages give an opportunity to implement logging that is contextually appropriate. For example, you may not want to log a stack trace if someone goes to a non-existent link in your application. Let's start with a 404 handler first and we'll log a warning when it happens along with the details about the failure. Switch over to your editor. I'm gonna close the terminals, so we can see more…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Why and what should I log?6m 26s
-
Problems with Node.js console6m 1s
-
(Locked)
Implementing Express error pages6m 48s
-
(Locked)
Choosing a logging library5m 40s
-
(Locked)
Adding Winston for Node logging4m 41s
-
(Locked)
Request logging with Morgan6m 39s
-
(Locked)
Correlating requests in logs6m 18s
-
(Locked)
Cross-application request correlation5m 32s
-
(Locked)
Challenge: Cross-application request IDs2m 14s
-
(Locked)
Solution: Cross-application request IDs9m 30s
-
(Locked)
-
-
-