.. _handling_command_errors: Handling command errors with JavaScript “Promise” feature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The use of the new JavaScript ‘Promise’ feature is encouraged to handle any request errors. For example: .. code-block:: javascript okular.Reboot().then(function(result) { console.log(result); // Success: stuff worked! }, function(err) { console.log(err); // Error: Maybe retry later. }); This applies for several functions like: .. code-block:: javascript okular.Beep(level), okular.SetFrontlight(level), okular.Sleep(periodMinutes), okular.SetHeartbeat(minutes), okular.TouchUpdate(), okular.ConfigureBattery(tresholdOff, tresholdOn, [tresholdCount = 1]), okular.SetVcom(vcomArray), okular.SetDisplayID(displayID) and okular.Reboot().