Error in Grails for interating Nexmo plugin

When I run this code:

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
            }
        }
    }
}

I get the following error message:

Error Compilation error: startup failed:
C:nexmo-mastergrails-appcontrollersnexmoSmsController.groovy: 19: unexpected token: catch @ line 19, column 13.
               catch (NexmoException e ) {
               ^

How do I resolve this issue?


尝试在catch语句之前关闭try语句。

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
}
链接地址: http://www.djcxy.com/p/33086.html

上一篇: Firebase SMS验证/身份验证

下一篇: Grails中插入Nexmo插件的错误