Summary
In this chapter, we have learned how error handling in Koa works out of the box. We have learned, with code examples, how to define and register our own custom error-handling middleware. We also learned about the error event in Koa and how to define listeners for centralized logging and other purposes.
The use of async... await in Koa makes error handling a lot easier than in traditional middleware-based frameworks, as we simply have to define try... catch statements to do most of the heavy lifting.
Proper error handling is a must-have for almost all applications going into production. This is another reason why Koa is such a great choice for production-grade HTTP applications.
In the next chapter, we will be building a Koa application ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access