2016-02-05 67 views
0

節儉0.9.2在這裏。這是我簡單led.thrift文件:節儉語法錯誤

namespace c_glib com.example.led 
namespace java com.example.led 

typedef i32 int 

enum LedState { 
    Off = 0, 
    On = 1 
} 

struct LedToggleCommand { 
    1: required int ledId; 
    2: required LedState state; 
} 

exception LedUnavailableException { 
    1: message; 
    2: cause; 
} 

service LedService { 
    oneway void toggle(1: LedToggleCommand cmd) throws (1: LedUnavailableException luex); 
} 

當我運行thrift --gen java led.thrift我收到以下錯誤:

[ERROR:/Users/myuser/tmp/thrift_samples/samples/led.thrift:17] (last token was ';') 
syntax error 
[FAILURE:/Users/myuser/tmp/thrift_samples/samples/led.thrift:17] Parser error during include pass. 

這是怎麼回事?

回答

1

您需要添加一些數據類型。

exception LedUnavailableException { 
    1: string message; 
    2: string cause; 
} 

此外,(至少)新版本會告訴你,...

[FAILURE:test.thrift:22] Oneway methods can't throw exceptions.