title: Catching multiple errors in Jenkins workflow
body: <p>My workflow sends mails when it fails using a try-catch. i have also enable concurrency and with this, when multiple jobs of the same workflow enters into a throttling stage, the new ones cancels the older ones. This throw an exception of <code>"org.jenkinsci.plugins.workflow.steps.FlowInterruptedException"</code> And canceled jobs also triggers the mail notification. </p>
  
  <p>Now i have modified my workflow to catch the specific <code>FlowInterruptedException</code> exception and suppress the mail notice and let anything else to trigger the mail, like so. </p>
  
  <pre><code>node {
  try {
  // some stages for the workflow
  }
  
  catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e){
  
          echo "the job was cancelled or aborted"
           }
  
   catch (err){ 
           stage 'Send Notification' 
           mail (to: 'adminj...@somename.com', 
           subject: "Job '${env.JOB_NAME}' (${env.BUILD_NUMBER}) has had an error.", 
                body: "Some text", 
              mimeType:'text/html'); 
           currentBuild.result = 'FAILURE' 
       } 
  
  }
  </code></pre>
  
  <p>This is catching only the <code>FlowInterruptedException</code> and when the job really fails due to any other reason (command typo, etc), i was expecting it will be caught by the other catch and will trigger the code inside it to send the mail. But it isn't. </p>
  
  <p>I think my code have some flaw in the try catch. Any idea?</p>
  
  <p>UPDATE:</p>
  
  <p>Just incase, if i use the below code it just send mail for just about any failures</p>
  
  <pre><code>node {
  try {
  // some stages for the workflow
  }
  
  catch (err){ 
           stage 'Send Notification' 
           mail (to: 'adminj...@somename.com', 
           subject: "Job '${env.JOB_NAME}' (${env.BUILD_NUMBER}) has had an error.", 
                body: "Some text", 
              mimeType:'text/html'); 
           currentBuild.result = 'FAILURE' 
       } 
  
  }
  </code></pre>