JavaScript Promises and Error Handling

Posted by: K. Scott Allen, on 01 Oct 2015 | View original | Bookmarked: 0 time(s)

Errors in asynchronous code typically require a messy number of if else checks and a careful inspection of parameter values. Promises allow asynchronous code to apply structured error handling. When using promises, you can pass an error handler to the then method or use a catch method to process errors. Just like exceptions in regular code, an exception or rejection in asynchronous code will jump to the nearest error handler. As an example, lets use the following functions which log the execution...

Category: Regex | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 371 | Hits: 10

Similar Posts

  • How to fix Sys.WebForms.PageRequestManagerParserErrorException in ASP.NET 2.0 AJAX 1.0 more
  • Deleting All Records In a Table EXCEPT For the N Most Recently Added Records more
  • Validation - Part 3 - Server-Side more
  • IIS 7 Error Pages taking over 500 Errors more
  • IDisposable and WCF more
  • Using the ClientAPI to retrieve safe JS strings for Localization in Gallery more
  • How to manage ASP.NET validation from Javascript with jQuery more
  • Doing away with an Assembly Dependency more
  • JavaScript exception instead of a message box more
  • Fix XML encoding in LINQ to SQL files to open up in RTM designer window more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD