0

このコードを実行すると:

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 ) {
               ^

この問題を解決するにはどうすればよいですか?

4

1 に答える 1

1

Try closing the try statement before you the catch statement.

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
}
于 2015-10-06T05:52:52.743 に答える