Cloud-side JavaScript "Promise" handling update

2018-07-03 06:16:00
102095
0
Blog picture

We are making our VoxEngine Cloud-side JavaScript API more standard compliant! Starting August 2018 rejected promises without a "catch" clause will trigger a scenario stop with an "Unhandled promise rejection" message. This brings our JavaScript engine in line with modern web browsers, making it easier to write correct scenarios. Not handling an exception at the root level or not handling a rejected promise at the root level is now handled the same way by explicitly notifying developers about possible problems with their code flow logic.

Before August 2018 update rejected top-level promises are not handled by our JavaScript engine:

AI.detectVoicemail(call)
  .then(e => {/* This code is executed if voicemail is detected */});
// But what happens if voicemail is NOT detected? Nothing. And that is wrong

After August 2018 update, the code above will stop JavaScript scenarios in case of a rejected promise, so developers can see an error message. The following code allows to explicitly specify what to do if a promise is rejected:

AI.detectVoicemail(call)
  .then(e => {/* This code is executed if voicemail is detected */})
  .catch(e => {/* This code is executed if voicemail is NOT detected */});
Sign Up for a free Voximplant developer account or talk to our experts

Add your comment

Name*
Email*
Message

Your comment has been added and will be published after moderation.

Recommended posts

What ISO 27001 Certification Is and Why We Need It

What ISO 27001 Certification Is and Why We Need It

The company was recently audited by the British Standards Institution (BSI) and was certified in relation to the process "Software Development and VoIP Solutions Based on the CPaaS Model" for compliance with the requirements of ISO/IEC 27001: 2013.

Product Management Leaders Podcast launch!

Product Management Leaders Podcast launch!

Hi all, we are happy to present the first episode of "The Product Management Leaders Podcast"! Our aim with this podcast is to connect you with some of the top PM leaders and share their real-world strategies and tactics for building world-class products with you. In today's episode, Grant Duncan speaks with Greg Montalvo, the Director of Product Management at Inmar, a 5,000+ person company.