Ошибка в Grails для взаимодействия с плагином Nexmo

Когда я запускаю этот код:

package nexmo

class SmsControllerController {

    // Inject the service
    def nexmoService

    def index() {
        def smsResult
        def callResult

        try {
            // Send the message "What's up?" to 1-500-123-4567
            smsResult = nexmoService.sendSms("61451062006", "What's up?")

            // Call the number and tell them a message
            callResult = nexmoService.call("61451062006", "Have a great day! Goodbye.")

            catch (NexmoException e ) {
                // Handle error if failure
            }
        }
    }
}

Я получаю следующее сообщение об ошибке:

Error Compilation error: startup failed:
C:\nexmo-master\grails-app\controllers\nexmo\SmsController.groovy: 19: unexpected token: catch @ line 19, column 13.
               catch (NexmoException e ) {
               ^

Как решить эту проблему?


person Peter Ha    schedule 06.10.2015    source источник


Ответы (1)


Попробуйте закрыть оператор try перед оператором catch.

try {
    // Send the message "What's up?" to 1-500-123-4567
    smsResult = nexmoService.sendSms("61451062006", "What's up?")

    // Call the number and tell them a message
    callResult = nexmoService.call("61451062006", "Have a great day! Goodbye.")
}
catch (NexmoException e ) {
        // Handle error if failure
}
person Sidharth Sharma    schedule 06.10.2015