title: Declarative vs Scripted Handling failures
body: <p>I see on Declarative Pipeline that it's done via "post" section really easy with conditions like 'always', 'failure', ...:</p>
  
  <p><a href="https://jenkins.io/doc/book/pipeline/syntax/#post" rel="noreferrer">https://jenkins.io/doc/book/pipeline/syntax/#post</a></p>
  
  <p>But with Scripted Pipeline there are no examples on how it's done:</p>
  
  <p>This link provides an example but only for "always" condition</p>
  
  <p><a href="https://jenkins.io/doc/book/pipeline/jenkinsfile/#handling-failures" rel="noreferrer">https://jenkins.io/doc/book/pipeline/jenkinsfile/#handling-failures</a></p>
  
  <p>I see this docs on how to set that result but I don't understand because with Declarative Pipeline you don't have to set it manually, plugins provided commands handle that for you.</p>
  
  <p><a href="https://support.cloudbees.com/hc/en-us/articles/218554077-How-to-set-current-build-result-in-Pipeline" rel="noreferrer">https://support.cloudbees.com/hc/en-us/articles/218554077-How-to-set-current-build-result-in-Pipeline</a></p>
  
  <p>Can anyone help me with this?</p>
  
  <p>For example if I do this:</p>
  
  <p>node {
     try {
       error 'Test error'
     } catch (ex) {
       echo 'Error handled'
     }
  }</p>
  
  <p>It doesn't trigger the "FAILURE" build status automatically and I don't see the echo. Why?</p>