Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140762

How to catch this exception in promise? [duplicate]

$
0
0

This question already has an answer here:

Consider the following code: particularly when "none" is selected. Using sweetalerts2

Swal.fire({ //
    html: '
    blah blah ',

    input: 'select',
    inputOptions: {
      'none': 'Please select an option:',
      'option1': 'First Option',
      'option2': 'Second Option'
    },
    inputValidator: function(value) {
      return new Promise(function(resolve, reject) {
        if (value != 'none') {
          resolve();
        } else {
          reject('You need to select an option');
        }
      });
    }
  }).then(function(theoption) {
      // etc etc...

On selecting "none", there is a javascript error. On firefox console, for example, I get "uncaught exception: You need to select an option" I realise that I am probably la hopeless Newbee


Viewing all articles
Browse latest Browse all 140762

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>