2011-08-10 63 views
0

我有一個簡短的問題。在我的Grails項目中,我正在進行一些Web服務調用。如果沒有足夠的字符進行搜索,其中一個調用(對於搜索功能而言)往往會超時。我無法增加所需字符的數量,因此我試圖捕捉異常並顯示一個錯誤頁面,要求用戶添加更詳細的參數。Apache錯誤與投擲類不兼容

的方法是這樣的:

import org.apache.http.client.HttpResponseException 

class RestSearchService implements SearchService { 
    List<Person> getPersonSearch(String fName, String lName) throws HttpResponseException { 
     ... 
     // Make the call 
     ... 
    } 
} 

我,然後趕上拋出的異常控制器重定向到錯誤頁面。我測試過了,這段代碼看起來很好。問題是,上面的方法有下劃線(我使用的是SpringSource工具套件的IDE),並說

Exception HttpResponseException is not compatible with 
throws clause in SearchService.getPersonSearch(String, String) 

有誰知道可能會導致什麼呢?另外,這是否意味着這會導致應用程序崩潰的實際問題或情況?就像我所說的,從我可以告訴throw/redirect像冠軍一樣工作,但是這個錯誤讓我擔心應用程序轉到生產。

由於提前,

-Mike

回答

1

我要說的是你的接口SearchService是不對的!接口中的方法'getPersonSearch'的簽名是什麼?

它是這樣的:

List<Person> getPersonSearch(String fName, String lName); 

或像這樣:

List<Person> getPersonSearch(String fName, String lName) throws HttpResponseException; 

第二個是正確的,如果你有第一個,這就是應該的問題!

+0

感謝您指出複製/粘貼錯誤 - 我已修復它!另外,你是絕對正確的,我忘了把錯誤丟到我的界面中。謝謝您的幫助! –