title: SweetAlert2 and promises
body: <p>I'm trying to use <a href="https://sweetalert2.github.io/" rel="nofollow noreferrer">SweetAlert2</a> but I'm having issues to display error messages when something goes wrong. Also, when the user presses the "Cancel" button, the console displays the error: Uncaught (in promise) cancel.</p>
  
  <p>In short, there is a button on my website. If the user presses that button a confirm dialog appears (using SweetAlert2). Here is my code:</p>
  
  <pre><code>swal({
      title: "Are you sure?",
      text: "You will not be able to undo this action!",
      type: "warning",
      showCancelButton: true,
      cancelButtonText: 'No, cancel!',
      confirmButtonColor: "#DD6B55",
      confirmButtonText: "Yes, do it!",
      allowOutsideClick: false
      preConfirm: function () {
          return axios.put('/api/endpoint')
          .then(response =&gt; {
              console.log('success')
          })
          .catch(error =&gt; {
              console.log('failure')
              swal({
                  title: "Something went wrong",
                  type: "error",
              })
          });
      }
  }).then(function (result) {
      if (result.value) {
          swal('Deleted!', 'Your file has been deleted.', 'success')
      } else if (result.dismiss === 'cancel') {
          swal('Cancelled', 'Your file is safe :)', 'error')
      }
  });
  </code></pre>
  
  <p>If something goes wrong, will be nice to display another SweetAlert2 dialog saying "Something went wrong", but instead of that, it looks like SweetAlert2 is somehow capturing the error and displaying it inside the same confirmation box. Also, there is the issue with the cancel button: If the user cancels, the console displays the already mentioned error.</p>
  
  <p>SweetAlert2 uses promises and I'm still learning how to use them properly, so maybe there is something that I'm doing in the wrong way.</p>
  
  <p>Any help, please?</p>
  
  <p>Thanks in advance</p>