Well, I prefer to define new Exception classes over ugly error codes, which 
better utilize OOP.

Tian Jiang

> 在 2019年8月13日,下午3:45,xiangdong Huang (JIRA) <[email protected]> 写道:
> 
> xiangdong Huang created IOTDB-161:
> -------------------------------------
> 
>             Summary: ERROR code is needed.
>                 Key: IOTDB-161
>                 URL: https://issues.apache.org/jira/browse/IOTDB-161
>             Project: Apache IoTDB
>          Issue Type: Task
>            Reporter: xiangdong Huang
> 
> 
> Now I think it is time to introduce error code.. 
> 
> For example, as IoTDB requires registering the time series first before 
> writing data, a kind of solution is:
> 
> ```
> 
> try{
> 
>   writeData();
> 
> } catch (SQLException e) {
> 
>   // the most case is that the time series does not exist.
> 
>   if (e.getMessage().contains("exist")) {
> 
>      //However, using the content of the error message  is not so efficient  
> 
>     registerTimeSeries();
> 
>     //write data once again
> 
>     writeData();
> 
>   }
> 
> }
> 
> ```
> 
> If we have error code, then we do not need to write ugly codes like ` if 
> (e.getMessage().contains("exist")) ` any more.
> 
>  
> 
> Some needed error codes that I can consider include:
> * create time series failed because there is no related storage group for the 
> given time series;
> * insert/query failed because the time series does not exist
> * insert/query failed because the value format is incorrect
> * sql parse error
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
> 
> 
> --
> This message was sent by Atlassian JIRA
> (v7.6.14#76016)


Reply via email to