groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mohan Radhakrishnan <radhakrishnan.mo...@gmail.com>
Subject Unknown type: METHOD_DEF
Date Fri, 05 Jan 2018 16:01:46 GMT
Hi,

         I am new to groovy. Here I tried to create

a simple wrapper around 'sleep'.

I see the error in the subject at 'def'. What's wrong ?

Thanks,

Mohan

/**
 * Our custom sleep logic.
 */
trait ThreadSleeper {
     long ms
     Closure cl = {}

    /*Sleep with an action taken*/
    def  sleeperWithAction() {
        try{

            Thread.sleep ms, cl

        }catch( InterruptedException ie ){
            throw new SleepInterruptedException( ie, "Thread.sleep is
interrupted for "+
                                                      "some reason ["
+ ie.getMessage() +"]");
        }
    }


    /*If there is no action to be taken then we call this*/
    def  sleeper() {
        try{

            Thread.sleep ms

        }catch( InterruptedException ie ){
            throw new SleepInterruptedException( ie, "Thread.sleep is
interrupted for "+
                                                     "some reason [" +
ie.getMessage() +"]");
        }
    }
}

Mime
View raw message