O'Reilly logo

JavaScript Promises Essentials by Rami Sarieddine

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Error Handling

As in any programming language, errors and exceptions are bound to rise; to ensure a smooth running code and easier debugging, we will need to throw and catch these exceptions. Handling errors with asynchronous JavaScript programming can be tedious. Promises, however, offer us a great mechanism to handle errors, which we will explore in this chapter. Throughout the previous chapter, we learned about the chaining of asynchronous operations. We also saw how we can transform from callback hell to the more readable and maintainable promise chains. In this chapter, we will cover the following topics:

  • Exceptions and error handling in promise
  • How to handle errors with promises using then and catch methods

Exceptions and promises ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required