Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-45469

Missing Pipeline DSL step exception is not caught by try-catch

      For example:

       

      node {
        try {
          nonExistingStep()
        } catch (e) {
          echo "exception caught !!!"
        }
      }
      

      catch block is not executed.

      Exception "java.lang.NoSuchMethodError: No such DSL method 'nonExistingStep'" is thrown anyway and build is failed.

       

          [JENKINS-45469] Missing Pipeline DSL step exception is not caught by try-catch

          Jesse Glick added a comment -

          This is known to work; I suspect Groovy treats an untyped catch clause as catching Exception, whereas this is an Error.

          Jesse Glick added a comment - This is known to work ; I suspect Groovy treats an untyped catch clause as catching Exception , whereas this is an Error .

          Jesse Glick added a comment -

          Indeed similar is reproducible from command-line groovy.

          Jesse Glick added a comment - Indeed similar is reproducible from command-line groovy .

          Catching Throwable works fine:

          catch(Throwable t) {
              throw e
          }
          

           

          https://stackoverflow.com/questions/38283476/java-nosuchmethoderror-not-caught-by-exception

          Taras Postument added a comment - Catching Throwable works fine: catch (Throwable t) { throw e }   https://stackoverflow.com/questions/38283476/java-nosuchmethoderror-not-caught-by-exception

          Jesse Glick added a comment -

          Better to catch NoSuchMethodError specifically, so you do not accidentally ignore unrelated problems.

          Jesse Glick added a comment - Better to catch NoSuchMethodError specifically, so you do not accidentally ignore unrelated problems.

            Unassigned Unassigned
            abeben Adam Beben
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: