Forum Discussion

trans-am's avatar
trans-am
Occasional Contributor
2 years ago

Try-Catch "No such property: carried for the class:" error

Following piece of groovy:   import groovy.json.JsonSlurper def response = context.expand( '${GetAccumulated#response}' ).toString() log.info(response) // This is OK. List is printed to the conso...
  • Shashavali's avatar
    2 years ago

    its because you define carried in the try block.

     

    please try to define carried before the try block.

     

    def carried

    try          {

                   carried = json.carriedFromPrevious  

                   log.info("carriedFromPrevious = " + carried) 

                   }

                   catch (Exception ex)

                            {

                            log.info("Respond not a number")

                            log.info(ex)

                            }

    log.info("carriedFromPrevious = " + carried) 

  • trans-am's avatar
    trans-am
    2 years ago

    Ok, works now. I had a little error in my script.